diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-05-27 15:32:18 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-05-27 15:34:56 +0200 |
commit | b26b5bba474e655fc56a24efa0a817b0188f3f54 (patch) | |
tree | 4ff0060ee4c2cfd3dfa612e65ad6eb938aefc936 | |
parent | e5463c962c95361b1f107a7b46cb90c9ad80ff24 (diff) | |
download | aurweb-b26b5bba474e655fc56a24efa0a817b0188f3f54.tar.xz |
UPGRADING: Create foreign key after modifying column
We cannot change a column after creating a foreign key:
ERROR 1832 (HY000): Cannot change column 'PackageBaseID': used in a
foreign key constraint 'Packages_ibfk_1'
Delay the "ADD FOREIGN KEY" command to fix this.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
-rw-r--r-- | UPGRADING | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -86,11 +86,11 @@ ALTER TABLE Packages 7. Add package base references to the Packages table: ---- +ALTER TABLE Packages ADD COLUMN PackageBaseID INTEGER UNSIGNED NULL; +UPDATE Packages SET PackageBaseID = ID; ALTER TABLE Packages - ADD COLUMN PackageBaseID INTEGER UNSIGNED NULL, + MODIFY PackageBaseID INTEGER UNSIGNED NOT NULL, ADD FOREIGN KEY (PackageBaseID) REFERENCES PackageBases(ID) ON DELETE CASCADE; -UPDATE Packages SET PackageBaseID = ID; -ALTER TABLE Packages MODIFY PackageBaseID INTEGER UNSIGNED NOT NULL; ---- 8. Delete foreign keys from PackageVotes, PackageComments and CommentNotify: |