0
0
Fork 0

Fix mentions.account_id and mentions.status_id not having NOT NULL database constraints (#30591)

This commit is contained in:
Claire 2024-06-07 15:45:11 +02:00 committed by GitHub
parent 37e4d96b70
commit 9e9613b286
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 47 additions and 5 deletions

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
class ChangeMentionStatusIdNonNullable < ActiveRecord::Migration[7.1]
def change
add_check_constraint :mentions, 'status_id IS NOT NULL', name: 'mentions_status_id_null', validate: false
end
end

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
class ValidateChangeMentionStatusIdNonNullable < ActiveRecord::Migration[7.1]
def up
validate_check_constraint :mentions, name: 'mentions_status_id_null'
change_column_null :mentions, :status_id, false
remove_check_constraint :mentions, name: 'mentions_status_id_null'
end
def down
add_check_constraint :mentions, 'status_id IS NOT NULL', name: 'mentions_status_id_null', validate: false
change_column_null :mentions, :status_id, true
end
end

View file

@ -0,0 +1,7 @@
# frozen_string_literal: true
class ChangeMentionAccountIdNonNullable < ActiveRecord::Migration[7.1]
def change
add_check_constraint :mentions, 'account_id IS NOT NULL', name: 'mentions_account_id_null', validate: false
end
end

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
class ValidateChangeMentionAccountIdNonNullable < ActiveRecord::Migration[7.1]
def up
validate_check_constraint :mentions, name: 'mentions_account_id_null'
change_column_null :mentions, :account_id, false
remove_check_constraint :mentions, name: 'mentions_account_id_null'
end
def down
add_check_constraint :mentions, 'account_id IS NOT NULL', name: 'mentions_account_id_null', validate: false
change_column_null :mentions, :account_id, true
end
end