debian-mirror-gitlab/db/post_migrate/20230112051854_add_not_null_constraint_to_o_auth_access_tokens_expires_in.rb
2023-04-23 21:23:45 +05:30

18 lines
654 B
Ruby

# frozen_string_literal: true
class AddNotNullConstraintToOAuthAccessTokensExpiresIn < Gitlab::Database::Migration[2.1]
disable_ddl_transaction!
def up
# validate: false ensures that existing records are not affected
# https://docs.gitlab.com/ee/development/database/not_null_constraints.html#prevent-new-invalid-records-current-release
add_not_null_constraint :oauth_access_tokens, :expires_in, validate: false
change_column_default :oauth_access_tokens, :expires_in, 7200
end
def down
remove_not_null_constraint :oauth_access_tokens, :expires_in
change_column_default :oauth_access_tokens, :expires_in, nil
end
end