mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-21 00:29:47 +00:00
Add NOT NULL
requirement to columns on account_conversations
(#33308)
This commit is contained in:
parent
a596f3479b
commit
cf4595967b
|
@ -5,13 +5,13 @@
|
||||||
# Table name: account_conversations
|
# Table name: account_conversations
|
||||||
#
|
#
|
||||||
# id :bigint(8) not null, primary key
|
# id :bigint(8) not null, primary key
|
||||||
# account_id :bigint(8)
|
# lock_version :integer default(0), not null
|
||||||
# conversation_id :bigint(8)
|
|
||||||
# participant_account_ids :bigint(8) default([]), not null, is an Array
|
# participant_account_ids :bigint(8) default([]), not null, is an Array
|
||||||
# status_ids :bigint(8) default([]), not null, is an Array
|
# status_ids :bigint(8) default([]), not null, is an Array
|
||||||
# last_status_id :bigint(8)
|
|
||||||
# lock_version :integer default(0), not null
|
|
||||||
# unread :boolean default(FALSE), not null
|
# unread :boolean default(FALSE), not null
|
||||||
|
# account_id :bigint(8) not null
|
||||||
|
# conversation_id :bigint(8) not null
|
||||||
|
# last_status_id :bigint(8)
|
||||||
#
|
#
|
||||||
|
|
||||||
class AccountConversation < ApplicationRecord
|
class AccountConversation < ApplicationRecord
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddNotNullToAccountConversationAccountColumn < ActiveRecord::Migration[7.2]
|
||||||
|
def change
|
||||||
|
add_check_constraint :account_conversations, 'account_id IS NOT NULL', name: 'account_conversations_account_id_null', validate: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class ValidateNotNullToAccountConversationAccountColumn < ActiveRecord::Migration[7.2]
|
||||||
|
def up
|
||||||
|
connection.execute(<<~SQL.squish)
|
||||||
|
DELETE FROM account_conversations
|
||||||
|
WHERE account_id IS NULL
|
||||||
|
SQL
|
||||||
|
|
||||||
|
validate_check_constraint :account_conversations, name: 'account_conversations_account_id_null'
|
||||||
|
change_column_null :account_conversations, :account_id, false
|
||||||
|
remove_check_constraint :account_conversations, name: 'account_conversations_account_id_null'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_check_constraint :account_conversations, 'account_id IS NOT NULL', name: 'account_conversations_account_id_null', validate: false
|
||||||
|
change_column_null :account_conversations, :account_id, true
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddNotNullToAccountConversationConversationColumn < ActiveRecord::Migration[7.2]
|
||||||
|
def change
|
||||||
|
add_check_constraint :account_conversations, 'conversation_id IS NOT NULL', name: 'account_conversations_conversation_id_null', validate: false
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class ValidateNotNullToAccountConversationConversationColumn < ActiveRecord::Migration[7.2]
|
||||||
|
def up
|
||||||
|
connection.execute(<<~SQL.squish)
|
||||||
|
DELETE FROM account_conversations
|
||||||
|
WHERE conversation_id IS NULL
|
||||||
|
SQL
|
||||||
|
|
||||||
|
validate_check_constraint :account_conversations, name: 'account_conversations_conversation_id_null'
|
||||||
|
change_column_null :account_conversations, :conversation_id, false
|
||||||
|
remove_check_constraint :account_conversations, name: 'account_conversations_conversation_id_null'
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
add_check_constraint :account_conversations, 'conversation_id IS NOT NULL', name: 'account_conversations_conversation_id_null', validate: false
|
||||||
|
change_column_null :account_conversations, :conversation_id, true
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.2].define(version: 2024_12_12_154346) do
|
ActiveRecord::Schema[7.2].define(version: 2024_12_13_170053) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_12_154346) do
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "account_conversations", force: :cascade do |t|
|
create_table "account_conversations", force: :cascade do |t|
|
||||||
t.bigint "account_id"
|
t.bigint "account_id", null: false
|
||||||
t.bigint "conversation_id"
|
t.bigint "conversation_id", null: false
|
||||||
t.bigint "participant_account_ids", default: [], null: false, array: true
|
t.bigint "participant_account_ids", default: [], null: false, array: true
|
||||||
t.bigint "status_ids", default: [], null: false, array: true
|
t.bigint "status_ids", default: [], null: false, array: true
|
||||||
t.bigint "last_status_id"
|
t.bigint "last_status_id"
|
||||||
|
|
Loading…
Reference in a new issue