bz_add_table should not have to remove the REFERENCES item when creating the table

RESOLVED FIXED in Bugzilla 4.2

Status

()

Bugzilla
Database
--
enhancement
RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: Max Kanat-Alexander, Assigned: Max Kanat-Alexander)

Tracking

3.7.2
Bugzilla 4.2

Details

Attachments

(1 attachment)

v1
16.89 KB, patch
Max Kanat-Alexander
: review+
Details | Diff | Splinter Review
(Assignee)

Description

8 years ago
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.
(Assignee)

Comment 1

8 years ago
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+
(Assignee)

Comment 2

8 years ago
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.