1 | | hi, i was working around to find the real cause of this issue and i am writing my observation here but i am not sure if they are fully correct or not, it would be really helpful if someone could cross-check/confirm. |
2 | | 1. when {{{a_ptr}}} is created its a primary key hence has UNIQUE constraint. |
3 | | 2. since {{{a_ptr}}} is a non nullable field it asks for a default value to populate the existing rows(even for empty db). And as we provide default value the UNIQUE constraint fails. |
4 | | 3. Now as UNIQUE constraints failed , it defies one of the rule of foreign key constraints given [https://www.sqlite.org/foreignkeys.html here] (Under the heading Required and Suggested Database Indexes) which says {{{The parent key columns named in the foreign key constraint are not the primary key of the parent table and are not subject to a unique constraint using collating sequence specified in the CREATE TABLE}}}. This subsequently leads to the {{{"foreign key mismatch - "models_c" referencing "models_b""}}} error. |
| 1 | ~~hi, i was working around to find the real cause of this issue and i am writing my observation here but i am not sure if they are fully correct or not, it would be really helpful if someone could cross-check/confirm.~~ |
| 2 | ~~1. when {{{a_ptr}}} is created its a primary key hence has UNIQUE constraint.~~ |
| 3 | ~~2. since {{{a_ptr}}} is a non nullable field it asks for a default value to populate the existing rows(even for empty db). And as we provide default value the UNIQUE constraint fails.~~ |
| 4 | ~~3. Now as UNIQUE constraints failed , it defies one of the rule of foreign key constraints given [https://www.sqlite.org/foreignkeys.html here] (Under the heading Required and Suggested Database Indexes) which says {{{The parent key columns named in the foreign key constraint are not the primary key of the parent table and are not subject to a unique constraint using collating sequence specified in the CREATE TABLE}}}. This subsequently leads to the {{{"foreign key mismatch - "models_c" referencing "models_b""}}} error.~~ |