From 14ef0460c873274a2c7ae54d6ba1504819302b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20G=C3=BCnther?= Date: Fri, 22 Sep 2017 15:55:47 +0200 Subject: [PATCH 1/2] Fix #771 Using `int` should suffice here, unless one needs the whole `unsigned` range, or one is worried about conversions actually producing negative values AND those creating problems. --- db/migrate/20170421101901_dmsf_file_container_rollback.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20170421101901_dmsf_file_container_rollback.rb b/db/migrate/20170421101901_dmsf_file_container_rollback.rb index 26bfffdc..90f308b4 100644 --- a/db/migrate/20170421101901_dmsf_file_container_rollback.rb +++ b/db/migrate/20170421101901_dmsf_file_container_rollback.rb @@ -69,7 +69,7 @@ class DmsfFileContainerRollback < ActiveRecord::Migration def down # dmsf_files - file_folder_ids = DmsfFile.joins(:dmsf_folder).where(:dmsf_folders => { :system => true }).pluck('dmsf_files.id, cast(dmsf_folders.title as unsigned)') + file_folder_ids = DmsfFile.joins(:dmsf_folder).where(:dmsf_folders => { :system => true }).pluck('dmsf_files.id, cast(dmsf_folders.title as int)') remove_index :dmsf_files, :project_id rename_column :dmsf_files, :project_id, :container_id add_column :dmsf_files, :project_id, :int, :null => true # temporarily added for the save method From 662f2eb3a6dc7a5b0060b78695b6d93303156676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20G=C3=BCnther?= Date: Fri, 22 Sep 2017 15:58:28 +0200 Subject: [PATCH 2/2] Fix #772 This makes the `CASE` expressions syntactically correct and uses the correct type for the new default values. --- db/migrate/20160217133001_status_deleted.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/migrate/20160217133001_status_deleted.rb b/db/migrate/20160217133001_status_deleted.rb index 3fa33b4b..9171a12f 100644 --- a/db/migrate/20160217133001_status_deleted.rb +++ b/db/migrate/20160217133001_status_deleted.rb @@ -43,13 +43,13 @@ class StatusDeleted < ActiveRecord::Migration case ActiveRecord::Base.connection.adapter_name.downcase when /postgresql/ execute 'ALTER TABLE dmsf_folders ALTER deleted DROP DEFAULT;' - change_column :dmsf_folders, :deleted, 'BOOLEAN USING CASE WHEN 1 THEN TRUE ELSE FALSE END', :null => false, :default => DmsfFolder::STATUS_ACTIVE + change_column :dmsf_folders, :deleted, 'BOOLEAN USING CASE WHEN deleted=1 THEN TRUE ELSE FALSE END', :null => false, :default => false execute 'ALTER TABLE dmsf_files ALTER deleted DROP DEFAULT;' - change_column :dmsf_files, :deleted, 'BOOLEAN USING CASE WHEN 1 THEN TRUE ELSE FALSE END', :null => false, :default => DmsfFile::STATUS_ACTIVE + change_column :dmsf_files, :deleted, 'BOOLEAN USING CASE WHEN deleted=1 THEN TRUE ELSE FALSE END', :null => false, :default => false execute 'ALTER TABLE dmsf_file_revisions ALTER deleted DROP DEFAULT;' - change_column :dmsf_file_revisions, :deleted, 'BOOLEAN USING CASE WHEN 1 THEN TRUE ELSE FALSE END', :null => false, :default => DmsfFileRevision::STATUS_ACTIVE + change_column :dmsf_file_revisions, :deleted, 'BOOLEAN USING CASE WHEN deleted=1 THEN TRUE ELSE FALSE END', :null => false, :default => false execute 'ALTER TABLE dmsf_links ALTER deleted DROP DEFAULT;' - change_column :dmsf_links, :deleted, 'BOOLEAN USING CASE WHEN 1 THEN TRUE ELSE FALSE END', :null => false, :default => DmsfLink::STATUS_ACTIVE + change_column :dmsf_links, :deleted, 'BOOLEAN USING CASE WHEN deleted=1 THEN TRUE ELSE FALSE END', :null => false, :default => false else change_column :dmsf_folders, :deleted, :boolean, :null => false, :default => false change_column :dmsf_files, :deleted, :boolean, :null => false, :default => false @@ -57,5 +57,5 @@ class StatusDeleted < ActiveRecord::Migration change_column :dmsf_links, :deleted, :boolean, :null => false, :default => false end end - -end \ No newline at end of file + +end