diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-02 06:08:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-02 06:08:01 +0300 |
commit | 796b00a98a82fcbe082c9343fd4efcccc77478dc (patch) | |
tree | 257bcb124f57cb91a8dff75e69649e8a2f91c51d /db/post_migrate | |
parent | 93dcf45d441bc884b167f4338380c8c888e9b86f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20200313203550_remove_orphaned_chat_names.rb | 13 | ||||
-rw-r--r-- | db/post_migrate/20200313204021_validate_foreign_key_from_chat_name_to_service.rb | 14 |
2 files changed, 27 insertions, 0 deletions
diff --git a/db/post_migrate/20200313203550_remove_orphaned_chat_names.rb b/db/post_migrate/20200313203550_remove_orphaned_chat_names.rb new file mode 100644 index 00000000000..59cd2b31772 --- /dev/null +++ b/db/post_migrate/20200313203550_remove_orphaned_chat_names.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class RemoveOrphanedChatNames < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + execute("DELETE FROM chat_names WHERE service_id NOT IN(SELECT id FROM services WHERE services.type = 'chat')") + end + + def down + say 'Orphaned user chat names were removed as a part of this migration and are non-recoverable' + end +end diff --git a/db/post_migrate/20200313204021_validate_foreign_key_from_chat_name_to_service.rb b/db/post_migrate/20200313204021_validate_foreign_key_from_chat_name_to_service.rb new file mode 100644 index 00000000000..fd9feab17db --- /dev/null +++ b/db/post_migrate/20200313204021_validate_foreign_key_from_chat_name_to_service.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class ValidateForeignKeyFromChatNameToService < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + DOWNTIME = false + + def up + validate_foreign_key :chat_names, :service_id + end + + def down + # no-op + end +end |