Instead of removing REFERENCES from columns when we create the table, we should simply note inside the schema object that the FK hasn't been created. Something like "created => 0". That will make things much easier in terms of re-creating FKs that we have to add, particularly for FKs that aren't in the ABSTRACT_SCHEMA, like the ones for multi-select fields.
Created attachment 457421 [details] [diff] [review] v1 Okay, this considerably simplifies the logical tracking of foreign keys in bz_schema (although it requires a bit more code on the inside of various functions). We now store FKs with an extra key, "created", in the _bz_real_schema. This tells us whether or not we've actually put the FK on to the disk, which still happens after all other changes are done. I've also added bz_alter_fk to make things easier for people who need to change FK definitions. You can't just drop an fk and expect checksetup to re-create it with a *new* definition, anymore, in 4.2. It will re-create it with its *existing* definition. So you need to use bz_alter_fk if you want to actually change the definition of an FK. You still don't have to specify REFERENCES during bz_add_column or bz_alter_column--Bugzilla::DB will figure that out for you.
Assignee: database → mkanat
Status: NEW → ASSIGNED
Attachment #457421 - Flags: review+
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/ modified Bugzilla/DB.pm modified Bugzilla/DB/Mysql.pm modified Bugzilla/DB/Oracle.pm modified Bugzilla/DB/Schema.pm modified Bugzilla/Install/DB.pm modified template/en/default/global/code-error.html.tmpl Committed revision 7365.
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.