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

Upgrade old DB scheme

Pre-2018 installation had a bad database scheme. This should fix it partly, and allow them to upgrade to wallabag 2.4.x.
See : https://github.com/YunoHost-Apps/wallabag2_ynh/pull/125
This commit is contained in:
lapineige 2022-03-14 16:02:03 +01:00 committed by GitHub
parent 1f2c63c417
commit 446f6ec717
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -158,6 +158,11 @@ then
ynh_replace_string --match_string="database_table_prefix: wallabag_" --replace_string="database_table_prefix: null" --target_file=$wb_conf
ynh_replace_string --match_string="secret: ovmpmAWXRCabNlMgzlzFXDYmCFfzGv" --replace_string="secret: $deskey" --target_file=$wb_conf
ynh_replace_string --match_string="domain_name: https://your-wallabag-url-instance.com" --replace_string="domain_name: https://$domain$path_url" --target_file=$wb_conf
# Migrate old (erroneous) database scheme (see: https://github.com/YunoHost-Apps/wallabag2_ynh/pull/125#issuecomment-1041426972)
ynh_script_progression --message="Migrating old (pre-2018) database scheme..." --weight=11
ynh_mysql_execute_as_root --sql="START TRANSACTION; ALTER TABLE oauth2_access_tokens DROP FOREIGN KEY 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 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 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 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 FK_D394478CA76ED395; ALTER TABLE oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE config DROP FOREIGN KEY FK_D48A2F7CA76ED395; ALTER TABLE config ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE entry DROP FOREIGN KEY FK_2B219D70A76ED395; ALTER TABLE entry ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE oauth2_auth_codes DROP FOREIGN KEY 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 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 FK_1AF95E7824DB0683; ALTER TABLE tagging_rule ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES config (id); COMMIT;" --database=$db_name
ynh_script_progression --message="Database migration done. Resuming normal upgrade process" --weight=11
#=================================================
# UPGRADE WALLABAG