1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wallabag2_ynh.git synced 2024-10-01 13:35:06 +02:00

Drop new constraint before creating it to avoid existing constraint issues

This commit is contained in:
Nicolas Frandeboeuf 2022-03-22 09:55:36 +01:00
parent 4e2d640538
commit 86404bd5ee

View file

@ -1,22 +1,43 @@
START TRANSACTION;
ALTER TABLE oauth2_access_tokens DROP FOREIGN KEY IF EXISTS FK_D247A21BA76ED395;
ALTER TABLE oauth2_access_tokens ADD CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE oauth2_access_tokens DROP FOREIGN KEY IF EXISTS FK_D247A21B19EB6921;
ALTER TABLE oauth2_access_tokens ADD CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id);
ALTER TABLE oauth2_auth_codes DROP FOREIGN KEY IF EXISTS FK_A018A10DA76ED395;
ALTER TABLE oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE oauth2_clients DROP FOREIGN KEY IF EXISTS FK_F9D02AE6A76ED395;
ALTER TABLE oauth2_clients ADD CONSTRAINT FK_635D765EA76ED395 FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE oauth2_refresh_tokens DROP FOREIGN KEY IF EXISTS FK_D394478CA76ED395;
ALTER TABLE oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE config DROP FOREIGN KEY IF EXISTS FK_D48A2F7CA76ED395;
ALTER TABLE config ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE entry DROP FOREIGN KEY IF EXISTS FK_2B219D70A76ED395;
ALTER TABLE entry ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE oauth2_auth_codes DROP FOREIGN KEY IF EXISTS FK_A018A10D19EB6921;
ALTER TABLE oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id);
ALTER TABLE oauth2_refresh_tokens DROP FOREIGN KEY IF EXISTS FK_D394478C19EB6921;
ALTER TABLE oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id);
ALTER TABLE tagging_rule DROP FOREIGN KEY IF EXISTS FK_1AF95E7824DB0683;
ALTER TABLE tagging_rule ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES config (id);
COMMIT;
# Drop old foreign keys
ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY IF EXISTS FK_D247A21BA76ED395;
ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY IF EXISTS FK_D247A21B19EB6921;
ALTER TABLE `oauth2_auth_codes` DROP FOREIGN KEY IF EXISTS FK_A018A10DA76ED395;
ALTER TABLE `oauth2_clients` DROP FOREIGN KEY IF EXISTS FK_F9D02AE6A76ED395;
ALTER TABLE `oauth2_refresh_tokens` DROP FOREIGN KEY IF EXISTS FK_D394478CA76ED395;
ALTER TABLE `config` DROP FOREIGN KEY IF EXISTS FK_D48A2F7CA76ED395;
ALTER TABLE `entry` DROP FOREIGN KEY IF EXISTS FK_2B219D70A76ED395;
ALTER TABLE `oauth2_auth_codes` DROP FOREIGN KEY IF EXISTS FK_A018A10D19EB6921;
ALTER TABLE `oauth2_refresh_tokens` DROP FOREIGN KEY IF EXISTS FK_D394478C19EB6921;
ALTER TABLE `tagging_rule` DROP FOREIGN KEY IF EXISTS FK_1AF95E7824DB0683;
# Add new constraint (drop it before to avoid existing constraint issue on newer versions where the key already exists)
ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY IF EXISTS FK_368A4209A76ED395;
ALTER TABLE `oauth2_access_tokens` ADD CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY IF EXISTS FK_368A420919EB6921;
ALTER TABLE `oauth2_access_tokens` ADD CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id);
ALTER TABLE `oauth2_auth_codes` DROP FOREIGN KEY IF EXISTS FK_EE52E3FAA76ED395;
ALTER TABLE `oauth2_auth_codes` ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE `oauth2_clients` DROP FOREIGN KEY IF EXISTS FK_635D765EA76ED395;
ALTER TABLE `oauth2_clients` ADD CONSTRAINT FK_635D765EA76ED395 FOREIGN KEY (`user_id`) REFERENCES `user` (`id`);
ALTER TABLE `oauth2_refresh_tokens` DROP FOREIGN KEY IF EXISTS FK_20C9FB24A76ED395;
ALTER TABLE `oauth2_refresh_tokens` ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE `config` DROP FOREIGN KEY IF EXISTS FK_87E64C53A76ED395;
ALTER TABLE `config` ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE `entry` DROP FOREIGN KEY IF EXISTS FK_F4D18282A76ED395;
ALTER TABLE `entry` ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);
ALTER TABLE `oauth2_auth_codes` DROP FOREIGN KEY IF EXISTS FK_EE52E3FA19EB6921;
ALTER TABLE `oauth2_auth_codes` ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id);
ALTER TABLE `oauth2_refresh_tokens` DROP FOREIGN KEY IF EXISTS FK_20C9FB2419EB6921;
ALTER TABLE `oauth2_refresh_tokens` ADD CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id);
ALTER TABLE `tagging_rule` DROP FOREIGN KEY IF EXISTS FK_2D9B3C5424DB0683;
ALTER TABLE `tagging_rule` ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES config (id);