Revert "Upstream 20240517"
This commit is contained in:
parent
9c006fd893
commit
f6dec44e95
2347 changed files with 26470 additions and 87494 deletions
|
@ -1,6 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RailsSettingsMigration < ActiveRecord::Migration[5.0]
|
||||
MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
|
||||
ActiveRecord::Migration[5.0]
|
||||
else
|
||||
ActiveRecord::Migration[4.2]
|
||||
end
|
||||
|
||||
class RailsSettingsMigration < MIGRATION_BASE_CLASS
|
||||
def self.up
|
||||
create_table :settings do |t|
|
||||
t.string :var, null: false
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
class AddInReplyToAccountIdToStatuses < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
add_column :statuses, :in_reply_to_account_id, :integer, null: true, default: nil
|
||||
add_column :statuses, :searchability, :integer
|
||||
add_column :statuses, :limited_scope, :integer
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
Status.unscoped.where.not(in_reply_to_id: nil).includes(:thread).find_each do |status|
|
||||
|
@ -14,9 +12,6 @@ class AddInReplyToAccountIdToStatuses < ActiveRecord::Migration[5.0]
|
|||
status.save(validate: false)
|
||||
end
|
||||
end
|
||||
|
||||
remove_column :statuses, :searchability
|
||||
remove_column :statuses, :limited_scope
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -2,17 +2,7 @@
|
|||
|
||||
class AddSearchIndexToAccounts < ActiveRecord::Migration[5.0]
|
||||
def up
|
||||
execute <<~SQL.squish
|
||||
CREATE INDEX search_index
|
||||
ON accounts
|
||||
USING gin(
|
||||
(
|
||||
setweight(to_tsvector('simple', accounts.display_name), 'A') ||
|
||||
setweight(to_tsvector('simple', accounts.username), 'B') ||
|
||||
setweight(to_tsvector('simple', coalesce(accounts.domain, '')), 'C')
|
||||
)
|
||||
)
|
||||
SQL
|
||||
execute 'CREATE INDEX search_index ON accounts USING gin((setweight(to_tsvector(\'simple\', accounts.display_name), \'A\') || setweight(to_tsvector(\'simple\', accounts.username), \'B\') || setweight(to_tsvector(\'simple\', coalesce(accounts.domain, \'\')), \'C\')));'
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -7,73 +7,80 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
|||
include Mastodon::MigrationHelpers
|
||||
include Mastodon::MigrationWarning
|
||||
|
||||
TABLE_COLUMN_MAPPING = [
|
||||
[:account_domain_blocks, :account_id],
|
||||
[:account_domain_blocks, :id],
|
||||
[:accounts, :id],
|
||||
[:blocks, :account_id],
|
||||
[:blocks, :id],
|
||||
[:blocks, :target_account_id],
|
||||
[:conversation_mutes, :account_id],
|
||||
[:conversation_mutes, :id],
|
||||
[:domain_blocks, :id],
|
||||
[:favourites, :account_id],
|
||||
[:favourites, :id],
|
||||
[:favourites, :status_id],
|
||||
[:follow_requests, :account_id],
|
||||
[:follow_requests, :id],
|
||||
[:follow_requests, :target_account_id],
|
||||
[:follows, :account_id],
|
||||
[:follows, :id],
|
||||
[:follows, :target_account_id],
|
||||
[:imports, :account_id],
|
||||
[:imports, :id],
|
||||
[:media_attachments, :account_id],
|
||||
[:media_attachments, :id],
|
||||
[:mentions, :account_id],
|
||||
[:mentions, :id],
|
||||
[:mutes, :account_id],
|
||||
[:mutes, :id],
|
||||
[:mutes, :target_account_id],
|
||||
[:notifications, :account_id],
|
||||
[:notifications, :from_account_id],
|
||||
[:notifications, :id],
|
||||
[:oauth_access_grants, :application_id],
|
||||
[:oauth_access_grants, :id],
|
||||
[:oauth_access_grants, :resource_owner_id],
|
||||
[:oauth_access_tokens, :application_id],
|
||||
[:oauth_access_tokens, :id],
|
||||
[:oauth_access_tokens, :resource_owner_id],
|
||||
[:oauth_applications, :id],
|
||||
[:oauth_applications, :owner_id],
|
||||
[:reports, :account_id],
|
||||
[:reports, :action_taken_by_account_id],
|
||||
[:reports, :id],
|
||||
[:reports, :target_account_id],
|
||||
[:session_activations, :access_token_id],
|
||||
[:session_activations, :user_id],
|
||||
[:session_activations, :web_push_subscription_id],
|
||||
[:settings, :id],
|
||||
[:settings, :thing_id],
|
||||
[:statuses, :account_id],
|
||||
[:statuses, :application_id],
|
||||
[:statuses, :in_reply_to_account_id],
|
||||
[:stream_entries, :account_id],
|
||||
[:stream_entries, :id],
|
||||
[:subscriptions, :account_id],
|
||||
[:subscriptions, :id],
|
||||
[:tags, :id],
|
||||
[:users, :account_id],
|
||||
[:users, :id],
|
||||
[:web_settings, :id],
|
||||
[:web_settings, :user_id],
|
||||
].freeze
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def migrate_columns(to_type)
|
||||
display_warning
|
||||
included_columns = [
|
||||
[:account_domain_blocks, :account_id],
|
||||
[:account_domain_blocks, :id],
|
||||
[:accounts, :id],
|
||||
[:blocks, :account_id],
|
||||
[:blocks, :id],
|
||||
[:blocks, :target_account_id],
|
||||
[:conversation_mutes, :account_id],
|
||||
[:conversation_mutes, :id],
|
||||
[:domain_blocks, :id],
|
||||
[:favourites, :account_id],
|
||||
[:favourites, :id],
|
||||
[:favourites, :status_id],
|
||||
[:follow_requests, :account_id],
|
||||
[:follow_requests, :id],
|
||||
[:follow_requests, :target_account_id],
|
||||
[:follows, :account_id],
|
||||
[:follows, :id],
|
||||
[:follows, :target_account_id],
|
||||
[:imports, :account_id],
|
||||
[:imports, :id],
|
||||
[:media_attachments, :account_id],
|
||||
[:media_attachments, :id],
|
||||
[:mentions, :account_id],
|
||||
[:mentions, :id],
|
||||
[:mutes, :account_id],
|
||||
[:mutes, :id],
|
||||
[:mutes, :target_account_id],
|
||||
[:notifications, :account_id],
|
||||
[:notifications, :from_account_id],
|
||||
[:notifications, :id],
|
||||
[:oauth_access_grants, :application_id],
|
||||
[:oauth_access_grants, :id],
|
||||
[:oauth_access_grants, :resource_owner_id],
|
||||
[:oauth_access_tokens, :application_id],
|
||||
[:oauth_access_tokens, :id],
|
||||
[:oauth_access_tokens, :resource_owner_id],
|
||||
[:oauth_applications, :id],
|
||||
[:oauth_applications, :owner_id],
|
||||
[:reports, :account_id],
|
||||
[:reports, :action_taken_by_account_id],
|
||||
[:reports, :id],
|
||||
[:reports, :target_account_id],
|
||||
[:session_activations, :access_token_id],
|
||||
[:session_activations, :user_id],
|
||||
[:session_activations, :web_push_subscription_id],
|
||||
[:settings, :id],
|
||||
[:settings, :thing_id],
|
||||
[:statuses, :account_id],
|
||||
[:statuses, :application_id],
|
||||
[:statuses, :in_reply_to_account_id],
|
||||
[:stream_entries, :account_id],
|
||||
[:stream_entries, :id],
|
||||
[:subscriptions, :account_id],
|
||||
[:subscriptions, :id],
|
||||
[:tags, :id],
|
||||
[:users, :account_id],
|
||||
[:users, :id],
|
||||
[:web_settings, :id],
|
||||
[:web_settings, :user_id],
|
||||
]
|
||||
included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
|
||||
|
||||
migration_duration_warning(<<~EXPLANATION)
|
||||
This migration has some sections that can be safely interrupted
|
||||
and restarted later, and will tell you when those are occurring.
|
||||
|
||||
For more information, see https://github.com/mastodon/mastodon/pull/5088
|
||||
EXPLANATION
|
||||
|
||||
tables = included_columns.map(&:first).uniq
|
||||
table_sizes = {}
|
||||
|
||||
# Sort tables by their size
|
||||
|
@ -96,25 +103,6 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
|
|||
end
|
||||
end
|
||||
|
||||
def display_warning
|
||||
migration_duration_warning(<<~EXPLANATION)
|
||||
This migration has some sections that can be safely interrupted
|
||||
and restarted later, and will tell you when those are occurring.
|
||||
|
||||
For more information, see https://github.com/mastodon/mastodon/pull/5088
|
||||
EXPLANATION
|
||||
end
|
||||
|
||||
def tables
|
||||
included_columns.map(&:first).uniq
|
||||
end
|
||||
|
||||
def included_columns
|
||||
TABLE_COLUMN_MAPPING.dup.tap do |included_columns|
|
||||
included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
|
||||
end
|
||||
end
|
||||
|
||||
def up
|
||||
migrate_columns(:bigint)
|
||||
end
|
||||
|
|
|
@ -5,15 +5,11 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
|||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :statuses, :searchability, :integer
|
||||
add_column :statuses, :limited_scope, :integer
|
||||
if supports_upsert?
|
||||
up_fast
|
||||
else
|
||||
up_slow
|
||||
end
|
||||
remove_column :statuses, :searchability
|
||||
remove_column :statuses, :limited_scope
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -24,7 +20,8 @@ class CopyStatusStats < ActiveRecord::Migration[5.2]
|
|||
private
|
||||
|
||||
def supports_upsert?
|
||||
ActiveRecord::Base.connection.database_version >= 90_500
|
||||
version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i
|
||||
version >= 90_500
|
||||
end
|
||||
|
||||
def up_fast
|
||||
|
|
|
@ -24,7 +24,8 @@ class CopyAccountStats < ActiveRecord::Migration[5.2]
|
|||
private
|
||||
|
||||
def supports_upsert?
|
||||
ActiveRecord::Base.connection.database_version >= 90_500
|
||||
version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i
|
||||
version >= 90_500
|
||||
end
|
||||
|
||||
def up_fast
|
||||
|
|
|
@ -4,8 +4,6 @@ class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
CustomEmoji.connection.execute('CREATE TABLE IF NOT EXISTS emoji_reactions (id integer, custom_emoji_id integer, created_at timestamp NOT NULL, updated_at timestamp NOT NULL)')
|
||||
|
||||
duplicates = CustomEmoji.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM custom_emojis GROUP BY shortcode, lower(domain) HAVING count(*) > 1').to_ary
|
||||
|
||||
duplicates.each do |row|
|
||||
|
@ -13,8 +11,6 @@ class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2]
|
|||
end
|
||||
|
||||
CustomEmoji.in_batches.update_all('domain = lower(domain)')
|
||||
|
||||
CustomEmoji.connection.execute('DROP TABLE IF EXISTS emoji_reactions')
|
||||
end
|
||||
|
||||
def down; end
|
||||
|
|
|
@ -5,8 +5,6 @@ class AddInstanceActor < ActiveRecord::Migration[5.2]
|
|||
# Dummy class, to make migration possible across version changes
|
||||
validates :username, uniqueness: { scope: :domain, case_sensitive: false }
|
||||
|
||||
INSTANCE_ACTOR_ID = -99
|
||||
|
||||
before_create :generate_keys
|
||||
|
||||
def generate_keys
|
||||
|
@ -17,10 +15,10 @@ class AddInstanceActor < ActiveRecord::Migration[5.2]
|
|||
end
|
||||
|
||||
def up
|
||||
Account.create!(id: Account::INSTANCE_ACTOR_ID, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
|
||||
Account.create!(id: -99, actor_type: 'Application', locked: true, username: Rails.configuration.x.local_domain)
|
||||
end
|
||||
|
||||
def down
|
||||
Account.find_by(id: Account::INSTANCE_ACTOR_ID, actor_type: 'Application').destroy!
|
||||
Account.find_by(id: -99, actor_type: 'Application').destroy!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,32 +9,9 @@ class AddCaseInsensitiveIndexToTags < ActiveRecord::Migration[5.2]
|
|||
redundant_tag_ids = row['ids'].split(',')[1..]
|
||||
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
UPDATE accounts_tags
|
||||
AS t0
|
||||
SET tag_id = #{canonical_tag_id}
|
||||
WHERE
|
||||
tag_id IN (#{redundant_tag_ids.join(', ')})
|
||||
AND NOT EXISTS (SELECT t1.tag_id FROM accounts_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)
|
||||
SQL
|
||||
|
||||
execute <<~SQL.squish
|
||||
UPDATE statuses_tags
|
||||
AS t0
|
||||
SET tag_id = #{canonical_tag_id}
|
||||
WHERE
|
||||
tag_id IN (#{redundant_tag_ids.join(', ')})
|
||||
AND NOT EXISTS (SELECT t1.tag_id FROM statuses_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.status_id = t0.status_id)
|
||||
SQL
|
||||
|
||||
execute <<~SQL.squish
|
||||
UPDATE featured_tags
|
||||
AS t0
|
||||
SET tag_id = #{canonical_tag_id}
|
||||
WHERE
|
||||
tag_id IN (#{redundant_tag_ids.join(', ')})
|
||||
AND NOT EXISTS (SELECT t1.tag_id FROM featured_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)
|
||||
SQL
|
||||
execute "UPDATE accounts_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM accounts_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)"
|
||||
execute "UPDATE statuses_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM statuses_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.status_id = t0.status_id)"
|
||||
execute "UPDATE featured_tags AS t0 SET tag_id = #{canonical_tag_id} WHERE tag_id IN (#{redundant_tag_ids.join(', ')}) AND NOT EXISTS (SELECT t1.tag_id FROM featured_tags AS t1 WHERE t1.tag_id = #{canonical_tag_id} AND t1.account_id = t0.account_id)"
|
||||
end
|
||||
|
||||
Tag.where(id: redundant_tag_ids).in_batches.delete_all
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class CreateAccountSummaries < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_view :account_summaries, materialized: true
|
||||
create_view :account_summaries, materialized: { no_data: true }
|
||||
|
||||
# To be able to refresh the view concurrently,
|
||||
# at least one unique index is required
|
||||
|
|
|
@ -6,7 +6,7 @@ class UpdateFollowRecommendationsToVersion2 < ActiveRecord::Migration[6.1]
|
|||
|
||||
def up
|
||||
drop_view :follow_recommendations
|
||||
create_view :follow_recommendations, version: 2, materialized: true
|
||||
create_view :follow_recommendations, version: 2, materialized: { no_data: true }
|
||||
|
||||
# To be able to refresh the view concurrently,
|
||||
# at least one unique index is required
|
||||
|
|
|
@ -3,26 +3,13 @@
|
|||
class FixCanonicalEmailBlocksForeignKey < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE canonical_email_blocks
|
||||
DROP CONSTRAINT fk_rails_1ecb262096,
|
||||
ADD CONSTRAINT fk_rails_1ecb262096
|
||||
FOREIGN KEY (reference_account_id)
|
||||
REFERENCES accounts(id)
|
||||
ON DELETE CASCADE
|
||||
SQL
|
||||
execute 'ALTER TABLE canonical_email_blocks DROP CONSTRAINT fk_rails_1ecb262096, ADD CONSTRAINT fk_rails_1ecb262096 FOREIGN KEY (reference_account_id) REFERENCES accounts(id) ON DELETE CASCADE;'
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
ALTER TABLE canonical_email_blocks
|
||||
DROP CONSTRAINT fk_rails_1ecb262096,
|
||||
ADD CONSTRAINT fk_rails_1ecb262096
|
||||
FOREIGN KEY (reference_account_id)
|
||||
REFERENCES accounts(id)
|
||||
SQL
|
||||
execute 'ALTER TABLE canonical_email_blocks DROP CONSTRAINT fk_rails_1ecb262096, ADD CONSTRAINT fk_rails_1ecb262096 FOREIGN KEY (reference_account_id) REFERENCES accounts(id);'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ class UpdateAccountSummariesToVersion2 < ActiveRecord::Migration[6.1]
|
|||
def up
|
||||
reapplication_follow_recommendations_v2 do
|
||||
drop_view :account_summaries, materialized: true
|
||||
create_view :account_summaries, version: 2, materialized: true
|
||||
create_view :account_summaries, version: 2, materialized: { no_data: true }
|
||||
safety_assured { add_index :account_summaries, :account_id, unique: true }
|
||||
end
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ class UpdateAccountSummariesToVersion2 < ActiveRecord::Migration[6.1]
|
|||
def down
|
||||
reapplication_follow_recommendations_v2 do
|
||||
drop_view :account_summaries, materialized: true
|
||||
create_view :account_summaries, version: 1, materialized: true
|
||||
create_view :account_summaries, version: 1, materialized: { no_data: true }
|
||||
safety_assured { add_index :account_summaries, :account_id, unique: true }
|
||||
end
|
||||
end
|
||||
|
@ -20,7 +20,7 @@ class UpdateAccountSummariesToVersion2 < ActiveRecord::Migration[6.1]
|
|||
def reapplication_follow_recommendations_v2
|
||||
drop_view :follow_recommendations, materialized: true
|
||||
yield
|
||||
create_view :follow_recommendations, version: 2, materialized: true
|
||||
create_view :follow_recommendations, version: 2, materialized: { no_data: true }
|
||||
safety_assured { add_index :follow_recommendations, :account_id, unique: true }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,16 +4,7 @@ class FixReblogDeletedAt < ActiveRecord::Migration[6.1]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
UPDATE statuses s
|
||||
SET deleted_at = r.deleted_at
|
||||
FROM statuses r
|
||||
WHERE
|
||||
s.reblog_of_id = r.id
|
||||
AND r.deleted_at IS NOT NULL
|
||||
SQL
|
||||
end
|
||||
safety_assured { execute 'UPDATE statuses s SET deleted_at = r.deleted_at FROM statuses r WHERE s.reblog_of_id = r.id AND r.deleted_at IS NOT NULL' }
|
||||
end
|
||||
|
||||
def down; end
|
||||
|
|
|
@ -7,13 +7,8 @@ class MoveUserSettings < ActiveRecord::Migration[6.1]
|
|||
|
||||
MAPPING = {
|
||||
default_privacy: 'default_privacy',
|
||||
default_searchability: 'default_searchability',
|
||||
default_sensitive: 'web.default_sensitive',
|
||||
default_language: 'default_language',
|
||||
public_post_to_unlisted: 'public_post_to_unlisted',
|
||||
reject_public_unlisted_subscription: 'reject_public_unlisted_subscription',
|
||||
reject_unlisted_subscription: 'reject_unlisted_subscription',
|
||||
send_without_domain_blocks: 'send_without_domain_blocks',
|
||||
noindex: 'noindex',
|
||||
theme: 'theme',
|
||||
trends: 'web.trends',
|
||||
|
@ -22,7 +17,6 @@ class MoveUserSettings < ActiveRecord::Migration[6.1]
|
|||
delete_modal: 'web.delete_modal',
|
||||
auto_play_gif: 'web.auto_play',
|
||||
display_media: 'web.display_media',
|
||||
display_media_expand: 'web.display_media_expand',
|
||||
expand_spoilers: 'web.expand_content_warnings',
|
||||
reduce_motion: 'web.reduce_motion',
|
||||
disable_swiping: 'web.disable_swiping',
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateEmojiReactions < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :emoji_reactions do |t|
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :name, null: false, default: ''
|
||||
t.belongs_to :custom_emoji, foreign_key: { on_delete: :cascade }
|
||||
t.string :uri
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEmojiReactionsToStatusStats < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :status_stats, :emoji_reactions, :string
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddImageSizeToCustomEmojis < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :custom_emojis, bulk: true do |t|
|
||||
t.integer :image_width
|
||||
t.integer :image_height
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_table :custom_emojis, bulk: true do |t|
|
||||
t.remove :image_width
|
||||
t.remove :image_height
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupMessageFollowingOnlyToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :group_message_following_only, :boolean
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupAllowPrivateMessageToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :group_allow_private_message, :boolean
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupActivityPubCountToAccountStats < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :account_stats, :group_activitypub_count, :integer
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateScheduledExpirationStatuses < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :scheduled_expiration_statuses do |t|
|
||||
t.belongs_to :account, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.datetime :scheduled_at, index: true
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSearchabilityToStatuses < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :statuses, :searchability, :integer
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSearchabilityToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :accounts, :searchability, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChangeSearchabilityDefaultValue < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
change_column_default :accounts, :searchability, from: 0, to: 2
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEmojiReactionsCountToStatusStats < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :status_stats, :emoji_reactions_count, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMarkdownToStatuses < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :statuses, :markdown, :boolean, default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMarkdownToStatusEdits < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :status_edits, :markdown, :boolean, default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEmojiReactionsCountPerAccountToStatusStats < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :status_stats, :emoji_reaction_accounts_count, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMinEmojisToAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :account_statuses_cleanup_policies, bulk: true do |t|
|
||||
t.integer :min_emojis
|
||||
t.boolean :keep_self_emoji, default: true, null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateAntennas < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :antennas do |t|
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :list, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :title, null: false, default: ''
|
||||
t.jsonb :keywords
|
||||
t.jsonb :exclude_keywords
|
||||
t.boolean :any_domains, null: false, default: true, index: true
|
||||
t.boolean :any_tags, null: false, default: true, index: true
|
||||
t.boolean :any_accounts, null: false, default: true, index: true
|
||||
t.boolean :any_keywords, null: false, default: true, index: true
|
||||
t.boolean :available, null: false, default: true, index: true
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
t.datetime :expires_at
|
||||
end
|
||||
create_table :antenna_domains do |t|
|
||||
t.belongs_to :antenna, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :name, index: true
|
||||
t.boolean :exclude, null: false, default: false, index: true
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
create_table :antenna_tags do |t|
|
||||
t.belongs_to :antenna, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :tag, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.boolean :exclude, null: false, default: false, index: true
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
create_table :antenna_accounts do |t|
|
||||
t.belongs_to :antenna, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.boolean :exclude, null: false, default: false, index: true
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddDissubscribableToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :antennas, :with_media_only, :boolean, null: false, default: false
|
||||
add_index :antennas, :with_media_only
|
||||
add_column :accounts, :dissubscribable, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddExcludesToAntennas < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :antennas, bulk: true do |t|
|
||||
t.jsonb :exclude_domains
|
||||
t.jsonb :exclude_accounts
|
||||
t.jsonb :exclude_tags
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_table :antennas, bulk: true do |t|
|
||||
t.remove :exclude_domains
|
||||
t.remove :exclude_accounts
|
||||
t.remove :exclude_tags
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRejectFavouriteToDomainBlocks < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :domain_blocks, bulk: true do |t|
|
||||
t.boolean :reject_favourite, null: false, default: false
|
||||
t.boolean :reject_reply, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,29 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRejectSendingToDomainBlocks < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :domain_blocks, bulk: true do |t|
|
||||
t.boolean :reject_send_not_public_searchability, null: false, default: false
|
||||
t.boolean :reject_send_unlisted_dissubscribable, null: false, default: false
|
||||
t.boolean :reject_send_public_unlisted, null: false, default: false
|
||||
t.boolean :reject_send_dissubscribable, null: false, default: false
|
||||
t.boolean :reject_send_media, null: false, default: false
|
||||
t.boolean :reject_send_sensitive, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_table :domain_blocks, bulk: true do |t|
|
||||
t.remove :reject_send_not_public_searchability
|
||||
t.remove :reject_send_unlisted_dissubscribable
|
||||
t.remove :reject_send_public_unlisted
|
||||
t.remove :reject_send_dissubscribable
|
||||
t.remove :reject_send_media
|
||||
t.remove :reject_send_sensitive
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSomeToDomainBlocks < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :domain_blocks, bulk: true do |t|
|
||||
t.boolean :reject_hashtag, null: false, default: false
|
||||
t.boolean :reject_straight_follow, null: false, default: false
|
||||
t.boolean :reject_new_follow, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_table :domain_blocks, bulk: true do |t|
|
||||
t.remove :reject_hashtag
|
||||
t.remove :reject_straight_follow
|
||||
t.remove :reject_new_follow
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddHiddenToDomainBlocks < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :domain_blocks, bulk: true do |t|
|
||||
t.boolean :hidden, null: false, default: false
|
||||
t.boolean :hidden_anonymous, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
change_table :domain_blocks, bulk: true do |t|
|
||||
t.remove :hidden
|
||||
t.remove :hidden_anonymous
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEmojiReactionStreamingToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :accounts, :stop_emoji_reaction_streaming, :boolean, default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRejectInvalidSubscriptionToDomainBlocks < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
safety_assured do
|
||||
remove_column :domain_blocks, :reject_send_unlisted_dissubscribable
|
||||
|
||||
change_table :domain_blocks do |t|
|
||||
t.boolean :detect_invalid_subscription, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
remove_column :domain_blocks, :detect_invalid_subscription
|
||||
|
||||
change_table :domain_blocks do |t|
|
||||
t.boolean :reject_send_unlisted_dissubscribable, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ChangeAntennasListToNullable < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
safety_assured do
|
||||
remove_foreign_key :antennas, :lists
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
add_foreign_key :antennas, :lists
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddStlToAntennas < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :antennas, :stl, :boolean, null: false, default: false
|
||||
add_index :antennas, :stl
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveStopEmojiReactionStreamingFromAccounts < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
safety_assured do
|
||||
remove_column :accounts, :stop_emoji_reaction_streaming
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
add_column :accounts, :stop_emoji_reaction_streaming, :boolean, null: true, default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIgnoreReblogToAntennas < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :antennas, :ignore_reblog, :boolean, null: false, default: false
|
||||
add_index :antennas, :ignore_reblog
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRejectReplyExcludeFollowersToDomainBlocks < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :domain_blocks do |t|
|
||||
t.boolean :reject_reply_exclude_followers, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddSettingsToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :settings, :jsonb
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddAliasesToCustomEmoji < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :custom_emojis, :aliases, :jsonb
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIsSensitiveToCustomEmojis < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
change_table :custom_emojis do |t|
|
||||
t.boolean :is_sensitive, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddLicenseToCustomEmojis < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :custom_emojis, :license, :string, null: true
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateStatusReferences < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :status_references do |t|
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :target_status, null: false, foreign_key: { on_delete: :cascade, to_table: :statuses }
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddStatusReferredByCountToStatusStats < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :status_stats, :status_referred_by_count, :integer, null: false, default: 0
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :status_stats, :status_referred_by_count
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddExcludeOptionsToFilters < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :custom_filters, :exclude_follows, :boolean, null: false, default: false
|
||||
add_column :custom_filters, :exclude_localusers, :boolean, null: false, default: false
|
||||
change_column_default :custom_filter_keywords, :whole_word, from: true, to: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateInstanceInfoes < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :instance_infos do |t|
|
||||
t.string :domain, null: false, default: '', index: { unique: true }
|
||||
t.string :software, null: false, default: ''
|
||||
t.string :version, null: false, default: ''
|
||||
t.jsonb :data, null: false, default: {}
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateStatusCapabilityToken < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :status_capability_tokens do |t|
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :token
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddLimitedScopeToStatuses < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :statuses, :limited_scope, :integer
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class CreateGlobalFollowRecommendations < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_view :global_follow_recommendations, materialized: true
|
||||
create_view :global_follow_recommendations, materialized: { no_data: true }
|
||||
safety_assured { add_index :global_follow_recommendations, :account_id, unique: true }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddNoInsertFeedsToAntennas < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class Antenna < ApplicationRecord
|
||||
end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :antennas, :insert_feeds, :boolean, default: false, null: false
|
||||
Antenna.where(insert_feeds: false).update_all(insert_feeds: true)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :antennas, :insert_feeds
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateCircles < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :circles do |t|
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :title, null: false, default: ''
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
create_table :circle_accounts do |t|
|
||||
t.belongs_to :circle, null: true, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :follow, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
|
||||
add_index :circle_accounts, [:circle_id, :account_id], unique: true
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddAntennaElementsUniqueness < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_index :antenna_accounts, [:antenna_id, :account_id], unique: true
|
||||
add_index :antenna_domains, [:antenna_id, :name], unique: true
|
||||
add_index :antenna_tags, [:antenna_id, :tag_id], unique: true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,27 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class CreateBookmarkCategories < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
create_table :bookmark_categories do |t|
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :title, null: false, default: ''
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
create_table :bookmark_category_statuses do |t|
|
||||
t.belongs_to :bookmark_category, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :bookmark, null: true, foreign_key: { on_delete: :cascade }
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
|
||||
add_index :bookmark_category_statuses, [:bookmark_category_id, :status_id], unique: true, algorithm: :concurrently, name: 'index_bc_statuses'
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddLtlToAntennas < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :antennas, :ltl, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddAttributeToStatusReferences < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :status_references, :attribute_type, :string
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class CreateCircleStatuses < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
create_table :circle_statuses do |t|
|
||||
t.belongs_to :circle, null: true, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
|
||||
add_index :circle_statuses, [:circle_id, :status_id], unique: true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,24 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddQuoteToStatusReferences < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class StatusReference < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :status_references, :quote, :boolean, default: false, null: false
|
||||
StatusReference.where(attribute_type: 'QT').update_all(quote: true)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
remove_column :status_references, :quote
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddQuoteToStatuses < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class StatusReference < ApplicationRecord
|
||||
belongs_to :status
|
||||
belongs_to :target_status, class_name: 'Status'
|
||||
end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :statuses, :quote_of_id, :bigint, default: nil, null: true
|
||||
|
||||
StatusReference.transaction do
|
||||
StatusReference.where(quote: true).includes(:status).find_each do |ref|
|
||||
ref.status.update(quote_of_id: ref.target_status_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
remove_column :statuses, :quote_of_id
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddWithQuoteToCustomFilters < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :custom_filters, :with_quote, :boolean, default: true, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,26 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class CreateFriendDomains < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
create_table :friend_domains do |t|
|
||||
t.string :domain, null: false, default: '', index: { unique: true }
|
||||
t.string :inbox_url, null: false, default: '', index: { unique: true }
|
||||
t.integer :active_state, null: false, default: 0
|
||||
t.integer :passive_state, null: false, default: 0
|
||||
t.string :active_follow_activity_id, null: true
|
||||
t.string :passive_follow_activity_id, null: true
|
||||
t.boolean :available, null: false, default: true
|
||||
t.boolean :pseudo_relay, null: false, default: false
|
||||
t.boolean :unlocked, null: false, default: false
|
||||
t.boolean :allow_all_posts, null: false, default: true
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddRejectFriendToDomainBlocks < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :domain_blocks, :reject_friend, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class ImproveSearchForAccountStatuses < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_index :statuses, [:account_id, :reblog_of_id, :deleted_at, :searchability], name: 'index_statuses_for_get_following_accounts_to_search', where: 'deleted_at IS NULL AND reblog_of_id IS NULL AND searchability IN (0, 10, 1)'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddDeliveryLocalToFriendDomains < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :friend_domains, :delivery_local, :boolean, default: true, null: false
|
||||
remove_column :friend_domains, :unlocked
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
remove_column :friend_domains, :delivery_local
|
||||
add_column :friend_domains, :unlocked, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToWebauthnCredentialsUserIdNickname < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index_to_table
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
remove_duplicates_and_reindex
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index_from_table
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_duplicates_and_reindex
|
||||
deduplicate_records
|
||||
reindex_records
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
retry
|
||||
end
|
||||
|
||||
def reindex_records
|
||||
remove_index_from_table
|
||||
add_index_to_table
|
||||
end
|
||||
|
||||
def add_index_to_table
|
||||
add_index :webauthn_credentials, [:user_id, :nickname], unique: true, algorithm: :concurrently
|
||||
end
|
||||
|
||||
def remove_index_from_table
|
||||
remove_index :webauthn_credentials, [:user_id, :nickname]
|
||||
end
|
||||
|
||||
def deduplicate_records
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
DELETE FROM webauthn_credentials
|
||||
WHERE id NOT IN (
|
||||
SELECT DISTINCT ON(user_id, nickname) id FROM webauthn_credentials
|
||||
ORDER BY user_id, nickname, id ASC
|
||||
)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToAccountAliasUriAccountId < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index_to_table
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
remove_duplicates_and_reindex
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index_from_table
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_duplicates_and_reindex
|
||||
deduplicate_records
|
||||
reindex_records
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
retry
|
||||
end
|
||||
|
||||
def reindex_records
|
||||
remove_index_from_table
|
||||
add_index_to_table
|
||||
end
|
||||
|
||||
def add_index_to_table
|
||||
add_index :account_aliases, [:account_id, :uri], unique: true, algorithm: :concurrently
|
||||
end
|
||||
|
||||
def remove_index_from_table
|
||||
remove_index :account_aliases, [:account_id, :uri]
|
||||
end
|
||||
|
||||
def deduplicate_records
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
DELETE FROM account_aliases
|
||||
WHERE id NOT IN (
|
||||
SELECT DISTINCT ON(account_id, uri) id FROM account_aliases
|
||||
ORDER BY account_id, uri, id ASC
|
||||
)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToCustomFilterStatusesStatusCustomFilter < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index_to_table
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
remove_duplicates_and_reindex
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index_from_table
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_duplicates_and_reindex
|
||||
deduplicate_records
|
||||
reindex_records
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
retry
|
||||
end
|
||||
|
||||
def reindex_records
|
||||
remove_index_from_table
|
||||
add_index_to_table
|
||||
end
|
||||
|
||||
def add_index_to_table
|
||||
add_index :custom_filter_statuses, [:status_id, :custom_filter_id], unique: true, algorithm: :concurrently
|
||||
end
|
||||
|
||||
def remove_index_from_table
|
||||
remove_index :custom_filter_statuses, [:status_id, :custom_filter_id]
|
||||
end
|
||||
|
||||
def deduplicate_records
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
DELETE FROM custom_filter_statuses
|
||||
WHERE id NOT IN (
|
||||
SELECT DISTINCT ON(status_id, custom_filter_id) id FROM custom_filter_statuses
|
||||
ORDER BY status_id, custom_filter_id, id ASC
|
||||
)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,49 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexToIdentitiesUidProvider < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index_to_table
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
remove_duplicates_and_reindex
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index_from_table
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_duplicates_and_reindex
|
||||
deduplicate_records
|
||||
reindex_records
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
retry
|
||||
end
|
||||
|
||||
def reindex_records
|
||||
remove_index_from_table
|
||||
add_index_to_table
|
||||
end
|
||||
|
||||
def add_index_to_table
|
||||
add_index :identities, [:uid, :provider], unique: true, algorithm: :concurrently
|
||||
end
|
||||
|
||||
def remove_index_from_table
|
||||
remove_index :identities, [:uid, :provider]
|
||||
end
|
||||
|
||||
def deduplicate_records
|
||||
safety_assured do
|
||||
execute <<~SQL.squish
|
||||
DELETE FROM identities
|
||||
WHERE id NOT IN (
|
||||
SELECT DISTINCT ON(uid, provider) id FROM identities
|
||||
ORDER BY uid, provider, id ASC
|
||||
)
|
||||
SQL
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class ConvertDtlForceSettings < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class User < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
User.transaction do
|
||||
User.find_in_batches do |users|
|
||||
users.filter { |user| user.settings.present? }.each do |user|
|
||||
json = Oj.load(user.settings, symbol_keys: true)
|
||||
dtl_force_with_tag = json.delete(:dtl_force_with_tag)
|
||||
next if dtl_force_with_tag.blank?
|
||||
|
||||
json[:dtl_force_visibility] = dtl_force_with_tag == 'full' ? 'unlisted' : 'unchange'
|
||||
json[:dtl_force_searchability] = dtl_force_with_tag == 'none' ? 'unchange' : 'public'
|
||||
user.update(settings: Oj.dump(json))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
User.transaction do
|
||||
User.find_in_batches do |users|
|
||||
users.filter { |user| user.settings.present? }.each do |user|
|
||||
json = Oj.load(user.settings, symbol_keys: true)
|
||||
dtl_force_visibility = json.delete(:dtl_force_visibility)
|
||||
dtl_force_searchability = json.delete(:dtl_force_searchability)
|
||||
next unless dtl_force_visibility.present? || dtl_force_searchability.present?
|
||||
|
||||
json[:dtl_force_with_tag] = case dtl_force_visibility
|
||||
when 'unlisted'
|
||||
'full'
|
||||
else
|
||||
dtl_force_searchability == 'unchange' ? 'none' : 'searchability'
|
||||
end
|
||||
user.update(settings: Oj.dump(json))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,22 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class CreateListStatuses < ActiveRecord::Migration[7.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
create_table :list_statuses do |t|
|
||||
t.belongs_to :list, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
|
||||
add_index :list_statuses, [:list_id, :status_id], unique: true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddNotifyToList < ActiveRecord::Migration[7.0]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :lists, :notify, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddMasterSettingsToAccounts < ActiveRecord::Migration[7.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
class Account < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
add_column :accounts, :master_settings, :jsonb
|
||||
|
||||
ActiveRecord::Base.connection.execute("UPDATE accounts SET master_settings = json_build_object('subscription_policy', 'block') WHERE accounts.dissubscribable IS TRUE")
|
||||
ActiveRecord::Base.connection.execute("UPDATE accounts SET master_settings = json_build_object('subscription_policy', 'allow') WHERE accounts.dissubscribable IS FALSE")
|
||||
|
||||
remove_column :accounts, :dissubscribable
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
add_column :accounts, :dissubscribable, :boolean, default: false, null: false
|
||||
|
||||
ActiveRecord::Base.connection.execute("UPDATE accounts SET dissubscribable = TRUE WHERE master_settings ->> 'subscription_policy' = 'block'")
|
||||
ActiveRecord::Base.connection.execute("UPDATE accounts SET dissubscribable = FALSE WHERE master_settings ->> 'subscription_policy' = 'allow'")
|
||||
|
||||
remove_column :accounts, :master_settings
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||
|
||||
class AddInboxURLToConversations < ActiveRecord::Migration[7.1]
|
||||
include Mastodon::MigrationHelpers
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :conversations, :inbox_url, :string, default: nil, null: true
|
||||
add_column :conversations, :ancestor_status_id, :bigint, default: nil, null: true
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexOnConversationsAncestorStatusId < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :conversations, :ancestor_status_id, where: 'ancestor_status_id IS NOT NULL', algorithm: :concurrently
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddIndexOnStatusesConversationId < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :statuses, :conversation_id, algorithm: :concurrently
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddOtpSecretToUser < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :users, :otp_secret, :string
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ImproveIndexForPublicTimelineSpeed < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index :statuses, [:id, :account_id], name: :index_statuses_local_20231213, algorithm: :concurrently, order: { id: :desc },
|
||||
where: '(local OR (uri IS NULL)) AND deleted_at IS NULL AND visibility IN (0, 10, 11) AND reblog_of_id IS NULL AND ((NOT reply) OR (in_reply_to_account_id = account_id))'
|
||||
add_index :statuses, [:id, :account_id], name: :index_statuses_public_20231213, algorithm: :concurrently, order: { id: :desc }, where: 'deleted_at IS NULL AND visibility IN (0, 10, 11) AND reblog_of_id IS NULL AND ((NOT reply) OR (in_reply_to_account_id = account_id))'
|
||||
remove_index :statuses, name: :index_statuses_local_20190824
|
||||
remove_index :statuses, name: :index_statuses_public_20200119
|
||||
end
|
||||
|
||||
def down
|
||||
add_index :statuses, [:id, :account_id], name: :index_statuses_local_20190824, algorithm: :concurrently, order: { id: :desc }, where: '(local OR (uri IS NULL)) AND deleted_at IS NULL AND visibility = 0 AND reblog_of_id IS NULL AND ((NOT reply) OR (in_reply_to_account_id = account_id))'
|
||||
add_index :statuses, [:id, :account_id], name: :index_statuses_public_20200119, algorithm: :concurrently, order: { id: :desc }, where: 'deleted_at IS NULL AND visibility = 0 AND reblog_of_id IS NULL AND ((NOT reply) OR (in_reply_to_account_id = account_id))'
|
||||
remove_index :statuses, name: :index_statuses_local_20231213
|
||||
remove_index :statuses, name: :index_statuses_public_20231213
|
||||
end
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class IndexToStatusesURL < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_index :statuses, :url, name: :index_statuses_on_url, algorithm: :concurrently, opclass: :text_pattern_ops, where: 'url IS NOT NULL AND url <> uri'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_index :statuses, name: :index_statuses_on_url
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveHiddenAnonymousFromDomainBlocks < ActiveRecord::Migration[7.0]
|
||||
class DomainBlock < ApplicationRecord; end
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
DomainBlock.where(hidden_anonymous: true, hidden: false).update_all(hidden: true)
|
||||
remove_column :domain_blocks, :hidden_anonymous
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
add_column :domain_blocks, :hidden_anonymous, :boolean, null: false, default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateGeneratedAnnualReports < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :generated_annual_reports do |t|
|
||||
t.belongs_to :account, null: false, foreign_key: { on_cascade: :delete }, index: false
|
||||
t.integer :year, null: false
|
||||
t.jsonb :data, null: false
|
||||
t.integer :schema_version, null: false
|
||||
t.datetime :viewed_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :generated_annual_reports, [:account_id, :year], unique: true
|
||||
end
|
||||
end
|
|
@ -1,14 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveUnusedTable < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
safety_assured do
|
||||
execute('DROP TABLE IF EXISTS account_groups CASCADE')
|
||||
execute('ALTER TABLE status_stats DROP COLUMN IF EXISTS test')
|
||||
end
|
||||
end
|
||||
|
||||
def down; end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddBlockTrendsToDomainBlocks < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_column :domain_blocks, :block_trends, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddUriToFavourites < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_column :favourites, :uri, :string
|
||||
add_index :favourites, :uri, unique: true, algorithm: :concurrently
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateNgwordHistories < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :ngword_histories do |t|
|
||||
t.string :uri, null: false
|
||||
t.integer :target_type, null: false
|
||||
t.integer :reason, null: false
|
||||
t.string :text, null: false
|
||||
t.string :keyword, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :ngword_histories, [:uri, :keyword, :created_at], unique: false
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddCountToNgwordHistories < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_column :ngword_histories, :count, :integer, null: false, default: 0
|
||||
|
||||
add_index :ngword_histories, [:uri, :reason, :created_at], unique: false, algorithm: :concurrently
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddRemotePendingToAccounts < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_column :accounts, :remote_pending, :boolean, null: false, default: false
|
||||
|
||||
add_index :accounts, :remote_pending, unique: false, algorithm: :concurrently
|
||||
end
|
||||
end
|
|
@ -1,8 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveDefaultsForStatusPinsTimestamps < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
change_column_default :status_pins, :created_at, from: -> { 'CURRENT_TIMESTAMP' }, to: nil
|
||||
change_column_default :status_pins, :updated_at, from: -> { 'CURRENT_TIMESTAMP' }, to: nil
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreatePendingFollowRequests < ActiveRecord::Migration[7.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
create_table :pending_follow_requests do |t|
|
||||
t.references :account, null: false, foreign_key: { on_delete: :cascade }, index: false
|
||||
t.references :target_account, null: false, foreign_key: { to_table: 'accounts', on_delete: :cascade }
|
||||
t.string :uri, null: false, index: { unique: true }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :pending_follow_requests, [:account_id, :target_account_id], unique: true
|
||||
end
|
||||
end
|
|
@ -1,64 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateNgRules < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :ng_rules do |t|
|
||||
t.string :title, null: false, default: ''
|
||||
t.boolean :available, null: false, default: true
|
||||
t.boolean :record_history_also_local, null: false, default: true
|
||||
t.string :account_domain, null: false, default: ''
|
||||
t.string :account_username, null: false, default: ''
|
||||
t.string :account_display_name, null: false, default: ''
|
||||
t.string :account_note, null: false, default: ''
|
||||
t.string :account_field_name, null: false, default: ''
|
||||
t.string :account_field_value, null: false, default: ''
|
||||
t.integer :account_avatar_state, null: false, default: 0
|
||||
t.integer :account_header_state, null: false, default: 0
|
||||
t.boolean :account_include_local, null: false, default: true
|
||||
t.boolean :account_allow_followed_by_local, null: false, default: false
|
||||
t.string :status_spoiler_text, null: false, default: ''
|
||||
t.string :status_text, null: false, default: ''
|
||||
t.string :status_tag, null: false, default: ''
|
||||
t.string :status_visibility, null: false, default: [], array: true
|
||||
t.string :status_searchability, null: false, default: [], array: true
|
||||
t.integer :status_media_state, null: false, default: 0
|
||||
t.integer :status_sensitive_state, null: false, default: 0
|
||||
t.integer :status_cw_state, null: false, default: 0
|
||||
t.integer :status_poll_state, null: false, default: 0
|
||||
t.integer :status_quote_state, null: false, default: 0
|
||||
t.integer :status_reply_state, null: false, default: 0
|
||||
t.integer :status_mention_state, null: false, default: 0
|
||||
t.integer :status_reference_state, null: false, default: 0
|
||||
t.integer :status_tag_threshold, null: false, default: -1
|
||||
t.integer :status_media_threshold, null: false, default: -1
|
||||
t.integer :status_poll_threshold, null: false, default: -1
|
||||
t.integer :status_mention_threshold, null: false, default: -1
|
||||
t.boolean :status_allow_follower_mention, null: false, default: true
|
||||
t.integer :status_reference_threshold, null: false, default: -1
|
||||
t.string :reaction_type, null: false, default: [], array: true
|
||||
t.boolean :reaction_allow_follower, null: false, default: true
|
||||
t.string :emoji_reaction_name, null: false, default: ''
|
||||
t.string :emoji_reaction_origin_domain, null: false, default: ''
|
||||
t.datetime :expires_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :ng_rule_histories do |t|
|
||||
t.belongs_to :ng_rule, null: false, foreign_key: { on_cascade: :delete }, index: false
|
||||
t.belongs_to :account, foreign_key: { on_cascade: :nullify }, index: false
|
||||
t.string :text
|
||||
t.string :uri, index: true
|
||||
t.integer :reason, null: false
|
||||
t.integer :reason_action, null: false
|
||||
t.boolean :local, null: false, default: true
|
||||
t.boolean :hidden, null: false, default: false
|
||||
t.jsonb :data
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :ng_rule_histories, [:ng_rule_id, :account_id]
|
||||
add_index :ng_rule_histories, :created_at
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddFilteredToNotifications < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :notifications, :filtered, :boolean, default: false, null: false
|
||||
end
|
||||
end
|
|
@ -1,18 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateNotificationRequests < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :notification_requests do |t|
|
||||
t.references :account, null: false, foreign_key: { on_delete: :cascade }, index: false
|
||||
t.references :from_account, null: false, foreign_key: { to_table: :accounts, on_delete: :cascade }
|
||||
t.references :last_status, null: false, foreign_key: { to_table: :statuses, on_delete: :nullify }
|
||||
t.bigint :notifications_count, null: false, default: 0
|
||||
t.boolean :dismissed, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :notification_requests, [:account_id, :from_account_id], unique: true
|
||||
add_index :notification_requests, [:account_id, :id], where: 'dismissed = false', order: { id: :desc }
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NotificationRequestIdsToTimestampIds < ActiveRecord::Migration[7.1]
|
||||
def up
|
||||
safety_assured do
|
||||
execute("ALTER TABLE notification_requests ALTER COLUMN id SET DEFAULT timestamp_id('notification_requests')")
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
execute('LOCK notification_requests')
|
||||
execute("SELECT setval('notification_requests_id_seq', (SELECT MAX(id) FROM notification_requests))")
|
||||
execute("ALTER TABLE notification_requests ALTER COLUMN id SET DEFAULT nextval('notification_requests_id_seq')")
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateNotificationPermissions < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :notification_permissions do |t|
|
||||
t.references :account, null: false, foreign_key: true
|
||||
t.references :from_account, null: false, foreign_key: { to_table: :accounts }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateNotificationPolicies < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :notification_policies do |t|
|
||||
t.references :account, null: false, foreign_key: true, index: { unique: true }
|
||||
t.boolean :filter_not_following, null: false, default: false
|
||||
t.boolean :filter_not_followers, null: false, default: false
|
||||
t.boolean :filter_new_accounts, null: false, default: false
|
||||
t.boolean :filter_private_mentions, null: false, default: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveGroupAttrsFromAccounts < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
safety_assured do
|
||||
remove_column :accounts, :group_allow_private_message, :boolean
|
||||
remove_column :account_stats, :group_activitypub_count, :integer
|
||||
end
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue