debian-mirror-gitlab/db/migrate/20221214204247_user_achievements_foreign_keys.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
719 B
Ruby
Raw Permalink Normal View History

2023-03-17 16:20:25 +05:30
# frozen_string_literal: true
class UserAchievementsForeignKeys < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
def up
add_concurrent_foreign_key :user_achievements, :users, column: :user_id, on_delete: :cascade
add_concurrent_foreign_key :user_achievements, :users, column: :awarded_by_user_id, on_delete: :nullify
add_concurrent_foreign_key :user_achievements, :users, column: :revoked_by_user_id, on_delete: :nullify
end
def down
with_lock_retries do
remove_foreign_key :user_achievements, column: :user_id
remove_foreign_key :user_achievements, column: :awarded_by_user_id
remove_foreign_key :user_achievements, column: :revoked_by_user_id
end
end
end