From 7c4aeec6a10bc4592da7a3dadbbf6edc08694051 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Wed, 17 Jun 2020 16:34:13 -0400 Subject: [PATCH] Changing column type [Needs Upgrade Notes] I do not believe this change column is likely used by adopters; It has to do with adding permissions to an individual Sipity::Entity. The change is necessary because the foreign key was created as a string, but the associated primary key on the other table was an integer. This is likely a bad copy paste job from ndlib/sipity --- .regen | 2 +- ...hange_sipity_entity_specific_responsibility.rb.erb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 lib/generators/hyrax/templates/db/migrate/20200617002029_change_sipity_entity_specific_responsibility.rb.erb diff --git a/.regen b/.regen index 6f4247a625..ae2f0b5bdb 100644 --- a/.regen +++ b/.regen @@ -1 +1 @@ -26 +26d diff --git a/lib/generators/hyrax/templates/db/migrate/20200617002029_change_sipity_entity_specific_responsibility.rb.erb b/lib/generators/hyrax/templates/db/migrate/20200617002029_change_sipity_entity_specific_responsibility.rb.erb new file mode 100644 index 0000000000..2f11a1cf91 --- /dev/null +++ b/lib/generators/hyrax/templates/db/migrate/20200617002029_change_sipity_entity_specific_responsibility.rb.erb @@ -0,0 +1,11 @@ +class ChangeSipityEntitySpecificResponsibility < ActiveRecord::Migration<%= migration_version %> + def change + if defined?(Sipity::EntitySpecificResponsibility) + if Sipity::EntitySpecificResponsibility.connect.adapter_name == "PostgreSQL" + change_column :sipity_entity_specific_responsibilities, :entity_id, 'integer USING CAST(entity_id AS integer)' + else + change_column :sipity_entity_specific_responsibilities, :entity_id, :integer + end + end + end +end