Add missing NOT NULL
requirement to small, indexed, valid data tables (#33284)
This commit is contained in:
parent
4130bda12e
commit
efc85e39a0
19 changed files with 198 additions and 33 deletions
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToAccountAliasColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM account_aliases
|
||||
WHERE account_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured { change_column_null :account_aliases, :account_id, false }
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { change_column_null :account_aliases, :account_id, true }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToAccountDeletionRequestColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM account_deletion_requests
|
||||
WHERE account_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured { change_column_null :account_deletion_requests, :account_id, false }
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { change_column_null :account_deletion_requests, :account_id, true }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToAccountDomainBlockColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM account_domain_blocks
|
||||
WHERE account_id IS NULL
|
||||
OR domain IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured do
|
||||
change_column_null :account_domain_blocks, :account_id, false
|
||||
change_column_null :account_domain_blocks, :domain, false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_column_null :account_domain_blocks, :account_id, true
|
||||
change_column_null :account_domain_blocks, :domain, true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToAdminActionLogColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM admin_action_logs
|
||||
WHERE account_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured { change_column_null :admin_action_logs, :account_id, false }
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { change_column_null :admin_action_logs, :account_id, true }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToAnnouncementMuteColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM announcement_mutes
|
||||
WHERE account_id IS NULL
|
||||
OR announcement_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured do
|
||||
change_column_null :announcement_mutes, :account_id, false
|
||||
change_column_null :announcement_mutes, :announcement_id, false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_column_null :announcement_mutes, :account_id, true
|
||||
change_column_null :announcement_mutes, :announcement_id, true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToAnnouncementReactionColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM announcement_reactions
|
||||
WHERE account_id IS NULL
|
||||
OR announcement_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured do
|
||||
change_column_null :announcement_reactions, :account_id, false
|
||||
change_column_null :announcement_reactions, :announcement_id, false
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_column_null :announcement_reactions, :account_id, true
|
||||
change_column_null :announcement_reactions, :announcement_id, true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToCustomFilterColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM custom_filters
|
||||
WHERE account_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured { change_column_null :custom_filters, :account_id, false }
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { change_column_null :custom_filters, :account_id, true }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToScheduledStatusColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM scheduled_statuses
|
||||
WHERE account_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured { change_column_null :scheduled_statuses, :account_id, false }
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { change_column_null :scheduled_statuses, :account_id, true }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddNotNullToUserInviteRequestColumns < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
connection.execute(<<~SQL.squish)
|
||||
DELETE FROM user_invite_requests
|
||||
WHERE user_id IS NULL
|
||||
SQL
|
||||
|
||||
safety_assured { change_column_null :user_invite_requests, :user_id, false }
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured { change_column_null :user_invite_requests, :user_id, true }
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue