diff options
Diffstat (limited to 'db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb')
-rw-r--r-- | db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb b/db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb new file mode 100644 index 00000000000..42c337fecff --- /dev/null +++ b/db/migrate/20200731201834_add_foreign_key_to_user_on_experiment_users.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class AddForeignKeyToUserOnExperimentUsers < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + with_lock_retries do + # There is no need to use add_concurrent_foreign_key since it's an empty table + add_foreign_key :experiment_users, :users, column: :user_id, on_delete: :cascade # rubocop:disable Migration/AddConcurrentForeignKey + end + end + + def down + with_lock_retries do + remove_foreign_key :experiment_users, column: :user_id + end + end +end |