diff --git a/config/initializers/0_acts_as_taggable.rb b/config/initializers/0_acts_as_taggable.rb index 04619590e3ca306367624c9a9a0d5fe7d795bb76..8dee3c52a53be96858a7d957d5d2bcf3027a67ed 100644 --- a/config/initializers/0_acts_as_taggable.rb +++ b/config/initializers/0_acts_as_taggable.rb @@ -11,8 +11,8 @@ ActsAsTaggableOn::Tagging.reflections["tag"].options[:counter_cache] ActsAsTaggableOn::Tagging.include IgnorableColumns -ActsAsTaggableOn::Tagging.ignore_column :id_convert_to_bigint, remove_with: '14.2', remove_after: '2021-08-22' -ActsAsTaggableOn::Tagging.ignore_column :taggable_id_convert_to_bigint, remove_with: '14.2', remove_after: '2021-08-22' +ActsAsTaggableOn::Tagging.ignore_column :id_convert_to_bigint, remove_with: '14.5', remove_after: '2021-10-22' +ActsAsTaggableOn::Tagging.ignore_column :taggable_id_convert_to_bigint, remove_with: '14.5', remove_after: '2021-10-22' # The tags and taggings are supposed to be part of `gitlab_ci` ActsAsTaggableOn::Tag.gitlab_schema = :gitlab_ci diff --git a/db/post_migrate/20210906130643_drop_temporary_columns_and_triggers_for_taggings.rb b/db/post_migrate/20210906130643_drop_temporary_columns_and_triggers_for_taggings.rb new file mode 100644 index 0000000000000000000000000000000000000000..cb5714055bb1408459b21cfbc0d83e024e90dc9f --- /dev/null +++ b/db/post_migrate/20210906130643_drop_temporary_columns_and_triggers_for_taggings.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class DropTemporaryColumnsAndTriggersForTaggings < Gitlab::Database::Migration[1.0] + enable_lock_retries! + + TABLE = 'taggings' + COLUMNS = %w(id taggable_id) + + # rubocop:disable Migration/WithLockRetriesDisallowedMethod + def up + cleanup_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end + # rubocop:enable Migration/WithLockRetriesDisallowedMethod + + def down + restore_conversion_of_integer_to_bigint(TABLE, COLUMNS) + end +end diff --git a/db/schema_migrations/20210906130643 b/db/schema_migrations/20210906130643 new file mode 100644 index 0000000000000000000000000000000000000000..150e594026d95899e1cdfc40c68865507bc8b5c1 --- /dev/null +++ b/db/schema_migrations/20210906130643 @@ -0,0 +1 @@ +c707c0879e439de95f24f8fe2084388276a46c5e0ee30e4134a43e22ca19b4ec \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 967ba5bc096c085a2842049d669743705d407a11..c46849e4391063cc3ff680fb1a13614317befb41 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -86,16 +86,6 @@ BEGIN END; $$; -CREATE FUNCTION trigger_aebe8b822ad3() RETURNS trigger - LANGUAGE plpgsql - AS $$ -BEGIN - NEW."id_convert_to_bigint" := NEW."id"; - NEW."taggable_id_convert_to_bigint" := NEW."taggable_id"; - RETURN NEW; -END; -$$; - CREATE TABLE audit_events ( id bigint NOT NULL, author_id integer NOT NULL, @@ -19414,9 +19404,7 @@ CREATE SEQUENCE system_note_metadata_id_seq ALTER SEQUENCE system_note_metadata_id_seq OWNED BY system_note_metadata.id; CREATE TABLE taggings ( - id_convert_to_bigint integer DEFAULT 0 NOT NULL, tag_id integer, - taggable_id_convert_to_bigint integer, taggable_type character varying, tagger_id integer, tagger_type character varying, @@ -27339,8 +27327,6 @@ ALTER INDEX product_analytics_events_experimental_pkey ATTACH PARTITION gitlab_p CREATE TRIGGER trigger_91dc388a5fe6 BEFORE INSERT OR UPDATE ON dep_ci_build_trace_sections FOR EACH ROW EXECUTE FUNCTION trigger_91dc388a5fe6(); -CREATE TRIGGER trigger_aebe8b822ad3 BEFORE INSERT OR UPDATE ON taggings FOR EACH ROW EXECUTE FUNCTION trigger_aebe8b822ad3(); - CREATE TRIGGER trigger_delete_project_namespace_on_project_delete AFTER DELETE ON projects FOR EACH ROW WHEN ((old.project_namespace_id IS NOT NULL)) EXECUTE FUNCTION delete_associated_project_namespace(); CREATE TRIGGER trigger_has_external_issue_tracker_on_delete AFTER DELETE ON integrations FOR EACH ROW WHEN ((((old.category)::text = 'issue_tracker'::text) AND (old.active = true) AND (old.project_id IS NOT NULL))) EXECUTE FUNCTION set_has_external_issue_tracker(); diff --git a/spec/migrations/20210906130643_drop_temporary_columns_and_triggers_for_taggings_spec.rb b/spec/migrations/20210906130643_drop_temporary_columns_and_triggers_for_taggings_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..2e7ce73337368f903414adc0290547aecadc422f --- /dev/null +++ b/spec/migrations/20210906130643_drop_temporary_columns_and_triggers_for_taggings_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration!('drop_temporary_columns_and_triggers_for_taggings') + +RSpec.describe DropTemporaryColumnsAndTriggersForTaggings do + let(:taggings_table) { table(:taggings) } + + it 'correctly migrates up and down' do + reversible_migration do |migration| + migration.before -> { + expect(taggings_table.column_names).to include('id_convert_to_bigint') + expect(taggings_table.column_names).to include('taggable_id_convert_to_bigint') + } + + migration.after -> { + taggings_table.reset_column_information + expect(taggings_table.column_names).not_to include('id_convert_to_bigint') + expect(taggings_table.column_names).not_to include('taggable_id_convert_to_bigint') + } + end + end +end