From 155629210ce569ac6535b209c50e109d589eda5e Mon Sep 17 00:00:00 2001 From: Tricia Jenkins Date: Fri, 15 Jan 2021 15:29:23 -0700 Subject: [PATCH 1/2] fixed symphony_nightly migration foreign key error When I try to rename the library_id column to backup_library_id a foreign key constraint is broken. The bug was hidden using MySQL 5.7 but not in MySQL 5.5 which is used by staging and production. By first removing the foreign key constraint then renaming the column and finally restoring the foreign key there aren't any invalid constriants at any time. --- CHANGELOG.md | 3 +++ docker-compose.lightweight.yml | 2 +- .../symphony_nightly/templates/update_symphony_nightly.erb | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb4afce0..54ee951db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and releases in Discovery project adheres to [Semantic Versioning](http://semver ## [Unreleased] +### Fixed +- symphony_nightly migration foreign key error [2142](https://github.com/ualbertalib/discovery/issues/2142) + ## [3.5.6] - 2021-01-05 ### Changed diff --git a/docker-compose.lightweight.yml b/docker-compose.lightweight.yml index 1830fcaec..72ebe0175 100644 --- a/docker-compose.lightweight.yml +++ b/docker-compose.lightweight.yml @@ -12,7 +12,7 @@ volumes: services: mysql: - image: mysql:5.7 + image: mysql:5.5 # matches staging/production environment: MYSQL_ROOT_PASSWORD: mysecretpassword volumes: diff --git a/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb b/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb index eab5d17c5..7c633f313 100644 --- a/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb +++ b/lib/generators/symphony_nightly/templates/update_symphony_nightly.erb @@ -16,8 +16,8 @@ class UpdateSymphonyNightly<%= Time.now.strftime('%Y%m%d') %> < ActiveRecord::Mi # Creating the locations table later on without this gives errors that were # difficult to to make sense of. foreign_keys('backup_locations').each do |fkey| + remove_foreign_key fkey.from_table, column: fkey.options[:column] rename_column fkey.from_table, fkey.options[:column], 'backup_' + fkey.options[:column] - remove_foreign_key fkey.from_table, fkey.to_table add_foreign_key fkey.from_table, fkey.to_table end @@ -56,8 +56,8 @@ class UpdateSymphonyNightly<%= Time.now.strftime('%Y%m%d') %> < ActiveRecord::Mi end foreign_keys('locations').each do |fkey| + remove_foreign_key fkey.from_table, column: fkey.options[:column] rename_column fkey.from_table, fkey.options[:column], fkey.options[:column].gsub('backup_', '') - remove_foreign_key fkey.from_table, fkey.to_table add_foreign_key fkey.from_table, fkey.to_table end From 0d7127001e7aef85f94c9c957fdf396436af7eaf Mon Sep 17 00:00:00 2001 From: Tricia Jenkins Date: Fri, 15 Jan 2021 15:33:14 -0700 Subject: [PATCH 2/2] bump CHANGELOG and VERSION for 3.5.7 release --- CHANGELOG.md | 2 ++ config/application.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54ee951db..b4b00a468 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and releases in Discovery project adheres to [Semantic Versioning](http://semver ## [Unreleased] +## [3.5.7] - 2021-01-15 + ### Fixed - symphony_nightly migration foreign key error [2142](https://github.com/ualbertalib/discovery/issues/2142) diff --git a/config/application.rb b/config/application.rb index dffefc657..a4b4e5bde 100755 --- a/config/application.rb +++ b/config/application.rb @@ -8,7 +8,7 @@ Bundler.require(*Rails.groups) module Discovery - VERSION = '3.5.6'.freeze # used in application layout meta generator tag + VERSION = '3.5.7'.freeze # used in application layout meta generator tag class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here.