diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-09-09 17:11:35 +0300 |
---|---|---|
committer | Alexandru Croitor <acroitor@gitlab.com> | 2019-09-10 11:00:38 +0300 |
commit | 8f91b9f0a8e565c3443253985af257dbcc67b8c0 (patch) | |
tree | 4c3b474f7c4bac73b34951be6c34e7eb9bb8ab73 | |
parent | 5059310e789a1a392e6401bb7ac826c9a0813eb8 (diff) | |
download | gitlab-ce-8f91b9f0a8e565c3443253985af257dbcc67b8c0.tar.gz |
Disable STI processing for migrations nested model classes
-rw-r--r-- | db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb | 5 | ||||
-rw-r--r-- | lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb b/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb index f042bcdf6e8..26990272277 100644 --- a/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb +++ b/db/post_migrate/20190715193142_migrate_discussion_id_on_promoted_epics.rb @@ -17,12 +17,13 @@ class MigrateDiscussionIdOnPromotedEpics < ActiveRecord::Migration[5.2] class SystemNoteMetadata < ActiveRecord::Base self.table_name = 'system_note_metadata' + self.inheritance_column = :_type_disabled end class Note < ActiveRecord::Base include EachBatch - has_one :system_note_metadata + has_one :system_note_metadata, class_name: 'MigrateDiscussionIdOnPromotedEpics::SystemNoteMetadata' self.table_name = 'notes' @@ -31,7 +32,7 @@ class MigrateDiscussionIdOnPromotedEpics < ActiveRecord::Migration[5.2] .joins(:system_note_metadata) .where(system: true) .where(noteable_type: 'Epic') - .where("system_note_metadata.action='moved'") + .where(system_note_metadata: { action: 'moved' }) .select("DISTINCT noteable_id") Note.where(noteable_type: 'Epic') diff --git a/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb b/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb index 9c3bb7c889b..1a80ccdee92 100644 --- a/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb +++ b/lib/gitlab/background_migration/fix_promoted_epics_discussion_ids.rb @@ -9,6 +9,7 @@ module Gitlab # notes model to iterate through the notes to be updated class Note < ActiveRecord::Base self.table_name = 'notes' + self.inheritance_column = :_type_disabled end def perform(discussion_ids) |