From 4499dda2ccffab82a7bce515a14e7053efd11889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 23 Apr 2025 10:41:29 +0200 Subject: [PATCH] SQL server compatibility --- db/migrate/07_dmsf_1_4_4.rb | 6 +++++- db/migrate/20170421101901_dmsf_file_container_rollback.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/db/migrate/07_dmsf_1_4_4.rb b/db/migrate/07_dmsf_1_4_4.rb index 90db352b..5f24124c 100644 --- a/db/migrate/07_dmsf_1_4_4.rb +++ b/db/migrate/07_dmsf_1_4_4.rb @@ -72,7 +72,11 @@ class Dmsf144 < ActiveRecord::Migration[4.2] t.change :lock_scope_cd, :integer, null: false # Data cleanup t.rename :dmsf_file_id, :entity_id - t.remove :locked + # TODO: The column cannot be removed on SQL server due to NOT NULL constraint. + # The constraint's name is random and therefore cannot be easily removed. + if ActiveRecord::Base.connection.adapter_name.downcase != 'sqlserver' + t.remove :locked + end end rename_table :dmsf_file_locks, :dmsf_locks # Not sure if this is the right place to do this, as its file manipulation, not database (strictly) diff --git a/db/migrate/20170421101901_dmsf_file_container_rollback.rb b/db/migrate/20170421101901_dmsf_file_container_rollback.rb index e9316716..5db41935 100644 --- a/db/migrate/20170421101901_dmsf_file_container_rollback.rb +++ b/db/migrate/20170421101901_dmsf_file_container_rollback.rb @@ -66,7 +66,11 @@ class DmsfFileContainerRollback < ActiveRecord::Migration[4.2] # Make DB changes in dmsf_files change_table :dmsf_files, bulk: true do |t| t.remove_index %i[container_id container_type] - t.remove :container_type + # TODO: The column cannot be removed on SQL server due to NOT NULL constraint. + # The constraint's name is random and therefore cannot be easily removed. + if ActiveRecord::Base.connection.adapter_name.downcase != 'sqlserver' + t.remove :container_type + end t.rename :container_id, :project_id t.index :project_id end