Skip to content

Commit

Permalink
Add foreign-keys-removal.sql for database migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamandar committed Jun 11, 2024
1 parent 571aa86 commit d345bc9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
12 changes: 12 additions & 0 deletions conf/foreign-keys-removal.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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;
10 changes: 9 additions & 1 deletion scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ source /usr/share/yunohost/helpers
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
# ynh_script_progression --message="Ensuring downward compatibility..."
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1

if ynh_compare_current_package_version --comparison lt --version "2.4~ynh1"; then
# 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_exec_warn_less ynh_mysql_execute_file_as_root --database="$db_name" --file="../conf/foreign-keys-removal.sql"
ynh_script_progression --message="Database migration done. Resuming normal upgrade process" --weight=11
fi

#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
Expand Down

0 comments on commit d345bc9

Please sign in to comment.