diff options
Diffstat (limited to 'db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb')
-rw-r--r-- | db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb b/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb deleted file mode 100644 index aae79c175bc..00000000000 --- a/db/migrate/20200408154411_add_path_locks_user_id_foreign_key.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -class AddPathLocksUserIdForeignKey < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - CONSTRAINT_NAME = 'fk_path_locks_user_id' - - disable_ddl_transaction! - - def up - with_lock_retries do - add_foreign_key(:path_locks, :users, on_delete: :cascade, validate: false, name: CONSTRAINT_NAME) - remove_foreign_key_if_exists(:path_locks, column: :user_id, on_delete: nil) - end - end - - def down - fk_exists = foreign_key_exists?(:path_locks, :users, column: :user_id, on_delete: nil) - - unless fk_exists - with_lock_retries do - add_foreign_key(:path_locks, :users, column: :user_id, validate: false) - end - end - - remove_foreign_key_if_exists(:path_locks, column: :user_id, name: CONSTRAINT_NAME) - - fk_name = concurrent_foreign_key_name(:path_locks, :user_id, prefix: 'fk_rails_') - validate_foreign_key(:path_locks, :user_id, name: fk_name) - end -end |