mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-29 14:35:06 +01:00
Add missing NOT NULL
requirement to small, indexed, valid data tables (#33284)
This commit is contained in:
parent
4130bda12e
commit
efc85e39a0
@ -5,11 +5,11 @@
|
||||
# Table name: account_aliases
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8)
|
||||
# acct :string default(""), not null
|
||||
# uri :string default(""), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class AccountAlias < ApplicationRecord
|
||||
|
@ -5,9 +5,9 @@
|
||||
# Table name: account_deletion_requests
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8) not null
|
||||
#
|
||||
class AccountDeletionRequest < ApplicationRecord
|
||||
DELAY_TO_DELETION = 30.days.freeze
|
||||
|
@ -5,10 +5,10 @@
|
||||
# Table name: account_domain_blocks
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# domain :string
|
||||
# domain :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8)
|
||||
# account_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class AccountDomainBlock < ApplicationRecord
|
||||
|
@ -5,15 +5,15 @@
|
||||
# Table name: admin_action_logs
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8)
|
||||
# action :string default(""), not null
|
||||
# human_identifier :string
|
||||
# permalink :string
|
||||
# route_param :string
|
||||
# target_type :string
|
||||
# target_id :bigint(8)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# human_identifier :string
|
||||
# route_param :string
|
||||
# permalink :string
|
||||
# account_id :bigint(8) not null
|
||||
# target_id :bigint(8)
|
||||
#
|
||||
|
||||
class Admin::ActionLog < ApplicationRecord
|
||||
|
@ -5,10 +5,10 @@
|
||||
# Table name: announcement_mutes
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8)
|
||||
# announcement_id :bigint(8)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8) not null
|
||||
# announcement_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class AnnouncementMute < ApplicationRecord
|
||||
|
@ -5,12 +5,12 @@
|
||||
# Table name: announcement_reactions
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8)
|
||||
# announcement_id :bigint(8)
|
||||
# name :string default(""), not null
|
||||
# custom_emoji_id :bigint(8)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8) not null
|
||||
# announcement_id :bigint(8) not null
|
||||
# custom_emoji_id :bigint(8)
|
||||
#
|
||||
|
||||
class AnnouncementReaction < ApplicationRecord
|
||||
|
@ -5,13 +5,13 @@
|
||||
# Table name: custom_filters
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8)
|
||||
# action :integer default("warn"), not null
|
||||
# context :string default([]), not null, is an Array
|
||||
# expires_at :datetime
|
||||
# phrase :text default(""), not null
|
||||
# context :string default([]), not null, is an Array
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# action :integer default("warn"), not null
|
||||
# account_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class CustomFilter < ApplicationRecord
|
||||
|
@ -5,9 +5,9 @@
|
||||
# Table name: scheduled_statuses
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8)
|
||||
# scheduled_at :datetime
|
||||
# params :jsonb
|
||||
# scheduled_at :datetime
|
||||
# account_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class ScheduledStatus < ApplicationRecord
|
||||
|
@ -5,10 +5,10 @@
|
||||
# Table name: user_invite_requests
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# user_id :bigint(8)
|
||||
# text :text
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :bigint(8) not null
|
||||
#
|
||||
|
||||
class UserInviteRequest < ApplicationRecord
|
||||
|
@ -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
|
26
db/schema.rb
26
db/schema.rb
@ -10,12 +10,12 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_12_12_154346) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
create_table "account_aliases", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.string "acct", default: "", null: false
|
||||
t.string "uri", default: "", null: false
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
@ -36,17 +36,17 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
end
|
||||
|
||||
create_table "account_deletion_requests", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
t.datetime "updated_at", precision: nil, null: false
|
||||
t.index ["account_id"], name: "index_account_deletion_requests_on_account_id"
|
||||
end
|
||||
|
||||
create_table "account_domain_blocks", force: :cascade do |t|
|
||||
t.string "domain"
|
||||
t.string "domain", null: false
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
t.datetime "updated_at", precision: nil, null: false
|
||||
t.bigint "account_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
|
||||
end
|
||||
|
||||
@ -213,7 +213,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
end
|
||||
|
||||
create_table "admin_action_logs", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.string "action", default: "", null: false
|
||||
t.string "target_type"
|
||||
t.bigint "target_id"
|
||||
@ -227,8 +227,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
end
|
||||
|
||||
create_table "announcement_mutes", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "announcement_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "announcement_id", null: false
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
t.datetime "updated_at", precision: nil, null: false
|
||||
t.index ["account_id", "announcement_id"], name: "index_announcement_mutes_on_account_id_and_announcement_id", unique: true
|
||||
@ -236,8 +236,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
end
|
||||
|
||||
create_table "announcement_reactions", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "announcement_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.bigint "announcement_id", null: false
|
||||
t.string "name", default: "", null: false
|
||||
t.bigint "custom_emoji_id"
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
@ -405,7 +405,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
end
|
||||
|
||||
create_table "custom_filters", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.datetime "expires_at", precision: nil
|
||||
t.text "phrase", default: "", null: false
|
||||
t.string "context", default: [], null: false, array: true
|
||||
@ -915,7 +915,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
end
|
||||
|
||||
create_table "scheduled_statuses", force: :cascade do |t|
|
||||
t.bigint "account_id"
|
||||
t.bigint "account_id", null: false
|
||||
t.datetime "scheduled_at", precision: nil
|
||||
t.jsonb "params"
|
||||
t.index ["account_id"], name: "index_scheduled_statuses_on_account_id"
|
||||
@ -1130,7 +1130,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_10_140838) do
|
||||
end
|
||||
|
||||
create_table "user_invite_requests", force: :cascade do |t|
|
||||
t.bigint "user_id"
|
||||
t.bigint "user_id", null: false
|
||||
t.text "text"
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
t.datetime "updated_at", precision: nil, null: false
|
||||
|
Loading…
Reference in New Issue
Block a user