about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200628105849_add_hidden_to_domain_allows.rb7
-rw-r--r--db/migrate/20200630222227_add_edited_to_statuses.rb10
-rw-r--r--db/migrate/20200630222517_backfill_default_statuses_edited.rb14
-rw-r--r--db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb7
-rw-r--r--db/migrate/20200706171939_add_not_null_to_monsterfork_additions.rb11
-rw-r--r--db/migrate/20200717014609_add_nest_level_to_statuses.rb7
-rw-r--r--db/migrate/20200718011317_add_require_dereference_to_accounts.rb7
-rw-r--r--db/migrate/20200719024610_add_show_replies_to_accounts.rb7
-rw-r--r--db/migrate/20200719033609_add_show_unlisted_to_accounts.rb7
-rw-r--r--db/migrate/20200719114344_add_timelines_only_to_mute.rb7
-rw-r--r--db/migrate/20200719181947_add_published_to_statuses.rb7
-rw-r--r--db/migrate/20200719184152_add_unpublished_index_to_statuses.rb7
-rw-r--r--db/migrate/20200720212317_create_status_mutes.rb10
-rw-r--r--db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb13
-rw-r--r--db/migrate/20200721195456_add_index_on_statuses_visibility.rb7
-rw-r--r--db/migrate/20200721202723_add_account_id_to_conversations.rb9
-rw-r--r--db/migrate/20200721221427_add_public_to_conversations.rb7
-rw-r--r--db/migrate/20200721221659_backfill_conversation_visibility.rb15
-rw-r--r--db/migrate/20200723225552_add_title_to_statuses.rb5
-rw-r--r--db/migrate/20200724035808_add_inline_to_media_attachments.rb7
-rw-r--r--db/migrate/20200724045955_create_inline_media_attachments.rb12
-rw-r--r--db/migrate/20200725071818_create_status_domain_permissions.rb13
-rw-r--r--db/migrate/20200725080000_create_account_domain_permissions.rb13
-rw-r--r--db/migrate/20200726094737_add_semiprivate_to_statuses.rb7
-rw-r--r--db/migrate/20200728135753_add_original_text_to_statuses.rb5
-rw-r--r--db/migrate/20200728171900_add_private_to_accounts.rb7
-rw-r--r--db/migrate/20200728173757_add_require_auth_to_accounts.rb7
-rw-r--r--db/migrate/20200731064236_create_account_metadata.rb10
-rw-r--r--db/migrate/20200731135033_backfill_account_metadata.rb11
-rw-r--r--db/migrate/20200731163700_create_destructing_statuses.rb11
-rw-r--r--db/migrate/20200731205913_create_queued_boosts.rb10
-rw-r--r--db/migrate/20200731211100_create_publishing_delays.rb10
-rw-r--r--db/migrate/20200801210543_add_accounts_to_publishing_delays.rb9
-rw-r--r--db/migrate/20200801220000_add_accounts_to_destructing_statuses.rb9
-rw-r--r--db/migrate/20200811024642_update_status_indexes.rb23
-rw-r--r--db/migrate/20200816200108_add_root_to_conversations.rb7
-rw-r--r--db/migrate/20200816200239_backfill_root_to_conversations.rb19
-rw-r--r--db/migrate/20200817003033_add_defaults_to_conversations.rb8
-rw-r--r--db/migrate/20200817003653_status_mute_account_id_bigint.rb7
-rw-r--r--db/migrate/20200817225525_add_footer_to_statuses.rb5
-rw-r--r--db/migrate/20200818040629_add_last_synced_at_to_accounts.rb5
-rw-r--r--db/migrate/20200818160057_create_collection_items.rb12
-rw-r--r--db/migrate/20200818160106_create_collection_pages.rb13
-rw-r--r--db/migrate/20200821051721_add_retries_to_collection_items.rb5
-rw-r--r--db/migrate/20200822054516_remove_public_column_from_conversations.rb7
-rw-r--r--db/migrate/20200823002835_unlink_blocked_replies.rb28
-rw-r--r--db/migrate/20200826125821_add_username_and_nospam_to_users.rb6
-rw-r--r--db/migrate/20200901035527_add_sticky_to_account_domain_permissions.rb7
-rw-r--r--db/migrate/20200901183004_backfill_user_username.rb11
-rw-r--r--db/migrate/20200904002209_add_expires_at_to_statuses.rb8
-rw-r--r--db/migrate/20200904004330_add_publish_at_to_statuses.rb8
-rw-r--r--db/migrate/20200904005553_drop_publishing_delay.rb5
-rw-r--r--db/migrate/20200904005706_drop_destructing_status.rb5
-rw-r--r--db/migrate/20200904184045_add_originally_local_only_to_statuses.rb7
-rw-r--r--db/migrate/20200904184155_backfill_originally_local_only.rb14
-rw-r--r--db/migrate/20200904200803_backfill_default_false_to_local_only.rb13
-rw-r--r--db/migrate/20200904201028_add_default_false_to_local_only.rb7
-rw-r--r--db/migrate/20200907195410_add_index_to_users_username.rb8
-rw-r--r--db/migrate/20200919234917_add_account_to_custom_emoji.rb7
-rw-r--r--db/migrate/20200920084007_backfill_custom_emoji_ownership.rb12
-rw-r--r--db/migrate/20200921024447_add_curated_to_statuses.rb7
-rw-r--r--db/migrate/20200921030158_backfill_curated_statuses.rb12
-rw-r--r--db/migrate/20200923000000_update_status_indexes_202009.rb25
-rw-r--r--db/migrate/20200923000001_remove_conversation_account.rb7
-rw-r--r--db/migrate/20200923000002_remove_semiprivate_flag.rb7
-rw-r--r--db/migrate/20200923000003_add_reblogs_flag_to_lists.rb8
-rw-r--r--db/migrate/20200925035221_drop_conversations_public.rb7
-rw-r--r--db/schema.rb125
68 files changed, 757 insertions, 3 deletions
diff --git a/db/migrate/20200628105849_add_hidden_to_domain_allows.rb b/db/migrate/20200628105849_add_hidden_to_domain_allows.rb
new file mode 100644
index 000000000..8fd4b79cc
--- /dev/null
+++ b/db/migrate/20200628105849_add_hidden_to_domain_allows.rb
@@ -0,0 +1,7 @@
+class AddHiddenToDomainAllows < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :domain_allows, :hidden, :boolean, default: false, allow_null: false
+    end
+  end
+end
diff --git a/db/migrate/20200630222227_add_edited_to_statuses.rb b/db/migrate/20200630222227_add_edited_to_statuses.rb
new file mode 100644
index 000000000..c0a5abb97
--- /dev/null
+++ b/db/migrate/20200630222227_add_edited_to_statuses.rb
@@ -0,0 +1,10 @@
+class AddEditedToStatuses < ActiveRecord::Migration[5.2]
+  def up
+    add_column :statuses, :edited, :int
+    change_column_default :statuses, :edited, 0
+  end
+
+  def down
+    remove_column :statuses, :edited
+  end
+end
diff --git a/db/migrate/20200630222517_backfill_default_statuses_edited.rb b/db/migrate/20200630222517_backfill_default_statuses_edited.rb
new file mode 100644
index 000000000..cbcbd600b
--- /dev/null
+++ b/db/migrate/20200630222517_backfill_default_statuses_edited.rb
@@ -0,0 +1,14 @@
+class BackfillDefaultStatusesEdited < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    Rails.logger.info('Backfilling "edited" column of table "statuses" to default value 0...')
+    Status.unscoped.in_batches do |statuses|
+      statuses.update_all(edited: 0)
+    end
+  end
+
+  def down
+    true
+  end
+end
diff --git a/db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb b/db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb
new file mode 100644
index 000000000..f35a2fc99
--- /dev/null
+++ b/db/migrate/20200702032702_add_conversation_id_index_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddConversationIdIndexToStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    safety_assured { add_index :statuses, :conversation_id, where: 'deleted_at IS NULL', algorithm: :concurrently, name: :index_statuses_on_conversation_id }
+  end
+end
diff --git a/db/migrate/20200706171939_add_not_null_to_monsterfork_additions.rb b/db/migrate/20200706171939_add_not_null_to_monsterfork_additions.rb
new file mode 100644
index 000000000..40b62f93a
--- /dev/null
+++ b/db/migrate/20200706171939_add_not_null_to_monsterfork_additions.rb
@@ -0,0 +1,11 @@
+class AddNotNullToMonsterforkAdditions < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      Rails.logger.info("Setting NOT NULL on domain_allows.hidden")
+      change_column_null :domain_allows, :hidden, false
+
+      Rails.logger.info("Setting NOT NULL on statuses.edited")
+      change_column_null :statuses, :edited, false
+    end
+  end
+end
diff --git a/db/migrate/20200717014609_add_nest_level_to_statuses.rb b/db/migrate/20200717014609_add_nest_level_to_statuses.rb
new file mode 100644
index 000000000..0b2196ad6
--- /dev/null
+++ b/db/migrate/20200717014609_add_nest_level_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddNestLevelToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :statuses, :nest_level, :integer, limit: 1, null: false, default: 0
+    end
+  end
+end
diff --git a/db/migrate/20200718011317_add_require_dereference_to_accounts.rb b/db/migrate/20200718011317_add_require_dereference_to_accounts.rb
new file mode 100644
index 000000000..9fcabd891
--- /dev/null
+++ b/db/migrate/20200718011317_add_require_dereference_to_accounts.rb
@@ -0,0 +1,7 @@
+class AddRequireDereferenceToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :accounts, :require_dereference, :boolean, null: false, default: false
+    end
+  end
+end
diff --git a/db/migrate/20200719024610_add_show_replies_to_accounts.rb b/db/migrate/20200719024610_add_show_replies_to_accounts.rb
new file mode 100644
index 000000000..ac6c5906b
--- /dev/null
+++ b/db/migrate/20200719024610_add_show_replies_to_accounts.rb
@@ -0,0 +1,7 @@
+class AddShowRepliesToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :accounts, :show_replies, :boolean, null: false, default: true
+    end
+  end
+end
diff --git a/db/migrate/20200719033609_add_show_unlisted_to_accounts.rb b/db/migrate/20200719033609_add_show_unlisted_to_accounts.rb
new file mode 100644
index 000000000..a9bb16720
--- /dev/null
+++ b/db/migrate/20200719033609_add_show_unlisted_to_accounts.rb
@@ -0,0 +1,7 @@
+class AddShowUnlistedToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :accounts, :show_unlisted, :boolean, null: false, default: true
+    end
+  end
+end
diff --git a/db/migrate/20200719114344_add_timelines_only_to_mute.rb b/db/migrate/20200719114344_add_timelines_only_to_mute.rb
new file mode 100644
index 000000000..20bbfcd59
--- /dev/null
+++ b/db/migrate/20200719114344_add_timelines_only_to_mute.rb
@@ -0,0 +1,7 @@
+class AddTimelinesOnlyToMute < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :mutes, :timelines_only, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200719181947_add_published_to_statuses.rb b/db/migrate/20200719181947_add_published_to_statuses.rb
new file mode 100644
index 000000000..129840a0c
--- /dev/null
+++ b/db/migrate/20200719181947_add_published_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddPublishedToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :statuses, :published, :boolean, default: true, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200719184152_add_unpublished_index_to_statuses.rb b/db/migrate/20200719184152_add_unpublished_index_to_statuses.rb
new file mode 100644
index 000000000..ee6d3e942
--- /dev/null
+++ b/db/migrate/20200719184152_add_unpublished_index_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddUnpublishedIndexToStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :statuses, [:account_id, :id], where: '(deleted_at IS NULL) AND (published = FALSE)', order: { id: :desc }, algorithm: :concurrently, name: :index_unpublished_statuses
+  end
+end
diff --git a/db/migrate/20200720212317_create_status_mutes.rb b/db/migrate/20200720212317_create_status_mutes.rb
new file mode 100644
index 000000000..efd8f15c8
--- /dev/null
+++ b/db/migrate/20200720212317_create_status_mutes.rb
@@ -0,0 +1,10 @@
+class CreateStatusMutes < ActiveRecord::Migration[5.2]
+  def change
+    create_table :status_mutes do |t|
+      t.integer :account_id, null: false, index: true
+      t.bigint :status_id, null: false, index: true
+    end
+
+    add_index :status_mutes, [:account_id, :status_id], unique: true
+  end
+end
diff --git a/db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb b/db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb
new file mode 100644
index 000000000..d22242bdd
--- /dev/null
+++ b/db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb
@@ -0,0 +1,13 @@
+class LimitVisibilityOfRepliesToPrivateStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    Status.includes(:thread).where.not(visibility: :direct).where(reply: true).where('statuses.in_reply_to_account_id != statuses.account_id').find_each do |status|
+      status.update!(visibility: status.thread.visibility) unless status.thread.nil? || %w(public unlisted).include?(status.thread.visibility) || ['direct', 'limited', status.thread.visibility].include?(status.visibility)
+    end
+  end
+
+  def down
+    true
+  end
+end
diff --git a/db/migrate/20200721195456_add_index_on_statuses_visibility.rb b/db/migrate/20200721195456_add_index_on_statuses_visibility.rb
new file mode 100644
index 000000000..c45405e95
--- /dev/null
+++ b/db/migrate/20200721195456_add_index_on_statuses_visibility.rb
@@ -0,0 +1,7 @@
+class AddIndexOnStatusesVisibility < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :statuses, :visibility, where: 'deleted_at IS NULL', algorithm: :concurrently, name: :index_statuses_on_visibility
+  end
+end
diff --git a/db/migrate/20200721202723_add_account_id_to_conversations.rb b/db/migrate/20200721202723_add_account_id_to_conversations.rb
new file mode 100644
index 000000000..afddf4823
--- /dev/null
+++ b/db/migrate/20200721202723_add_account_id_to_conversations.rb
@@ -0,0 +1,9 @@
+class AddAccountIdToConversations < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    safety_assured do
+      add_reference :conversations, :account, foreign_key: true, index: {algorithm: :concurrently}
+    end
+  end
+end
diff --git a/db/migrate/20200721221427_add_public_to_conversations.rb b/db/migrate/20200721221427_add_public_to_conversations.rb
new file mode 100644
index 000000000..392bd7418
--- /dev/null
+++ b/db/migrate/20200721221427_add_public_to_conversations.rb
@@ -0,0 +1,7 @@
+class AddPublicToConversations < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :conversations, :public, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200721221659_backfill_conversation_visibility.rb b/db/migrate/20200721221659_backfill_conversation_visibility.rb
new file mode 100644
index 000000000..93394b825
--- /dev/null
+++ b/db/migrate/20200721221659_backfill_conversation_visibility.rb
@@ -0,0 +1,15 @@
+class BackfillConversationVisibility < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    Rails.logger.info('Backfilling thread visibility...')
+
+    safety_assured do
+      execute('UPDATE conversations SET public = true FROM (SELECT account_id, conversation_id FROM statuses WHERE NOT reply AND visibility IN (0, 1)) AS s WHERE conversations.id = s.conversation_id')
+    end
+  end
+
+  def down
+    true
+  end
+end
diff --git a/db/migrate/20200723225552_add_title_to_statuses.rb b/db/migrate/20200723225552_add_title_to_statuses.rb
new file mode 100644
index 000000000..16ae7264b
--- /dev/null
+++ b/db/migrate/20200723225552_add_title_to_statuses.rb
@@ -0,0 +1,5 @@
+class AddTitleToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    add_column :statuses, :title, :text
+  end
+end
diff --git a/db/migrate/20200724035808_add_inline_to_media_attachments.rb b/db/migrate/20200724035808_add_inline_to_media_attachments.rb
new file mode 100644
index 000000000..171eca4b5
--- /dev/null
+++ b/db/migrate/20200724035808_add_inline_to_media_attachments.rb
@@ -0,0 +1,7 @@
+class AddInlineToMediaAttachments < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :media_attachments, :inline, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200724045955_create_inline_media_attachments.rb b/db/migrate/20200724045955_create_inline_media_attachments.rb
new file mode 100644
index 000000000..a894c3868
--- /dev/null
+++ b/db/migrate/20200724045955_create_inline_media_attachments.rb
@@ -0,0 +1,12 @@
+class CreateInlineMediaAttachments < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :inline_media_attachments do |t|
+      t.references :status, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
+      t.references :media_attachment, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
+    end
+
+    add_index :inline_media_attachments, [:status_id, :media_attachment_id], unique: true, algorithm: :concurrently, name: 'uniq_index_on_status_and_attachment'
+  end
+end
diff --git a/db/migrate/20200725071818_create_status_domain_permissions.rb b/db/migrate/20200725071818_create_status_domain_permissions.rb
new file mode 100644
index 000000000..e8faf3e00
--- /dev/null
+++ b/db/migrate/20200725071818_create_status_domain_permissions.rb
@@ -0,0 +1,13 @@
+class CreateStatusDomainPermissions < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :status_domain_permissions do |t|
+      t.references :status, null: false, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
+      t.string :domain, null: false, default: '', index: { algorithm: :concurrently }
+      t.integer :visibility, null: false, default: 0, index: { algorithm: :concurrently }
+    end
+
+    add_index :status_domain_permissions, [:status_id, :domain], unique: true, algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20200725080000_create_account_domain_permissions.rb b/db/migrate/20200725080000_create_account_domain_permissions.rb
new file mode 100644
index 000000000..2497eda69
--- /dev/null
+++ b/db/migrate/20200725080000_create_account_domain_permissions.rb
@@ -0,0 +1,13 @@
+class CreateAccountDomainPermissions < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :account_domain_permissions do |t|
+      t.references :account, null: false, index: { algorithm: :concurrently }, foreign_key: { on_delete: :cascade }
+      t.string :domain, null: false, default: '', index: { algorithm: :concurrently }
+      t.integer :visibility, null: false, default: 0, index: { algorithm: :concurrently }
+    end
+
+    add_index :account_domain_permissions, [:account_id, :domain], unique: true, algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20200726094737_add_semiprivate_to_statuses.rb b/db/migrate/20200726094737_add_semiprivate_to_statuses.rb
new file mode 100644
index 000000000..facde265c
--- /dev/null
+++ b/db/migrate/20200726094737_add_semiprivate_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddSemiprivateToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :statuses, :semiprivate, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200728135753_add_original_text_to_statuses.rb b/db/migrate/20200728135753_add_original_text_to_statuses.rb
new file mode 100644
index 000000000..6bf210191
--- /dev/null
+++ b/db/migrate/20200728135753_add_original_text_to_statuses.rb
@@ -0,0 +1,5 @@
+class AddOriginalTextToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    add_column :statuses, :original_text, :text
+  end
+end
diff --git a/db/migrate/20200728171900_add_private_to_accounts.rb b/db/migrate/20200728171900_add_private_to_accounts.rb
new file mode 100644
index 000000000..482d09576
--- /dev/null
+++ b/db/migrate/20200728171900_add_private_to_accounts.rb
@@ -0,0 +1,7 @@
+class AddPrivateToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :accounts, :private, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200728173757_add_require_auth_to_accounts.rb b/db/migrate/20200728173757_add_require_auth_to_accounts.rb
new file mode 100644
index 000000000..00a3c1642
--- /dev/null
+++ b/db/migrate/20200728173757_add_require_auth_to_accounts.rb
@@ -0,0 +1,7 @@
+class AddRequireAuthToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :accounts, :require_auth, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200731064236_create_account_metadata.rb b/db/migrate/20200731064236_create_account_metadata.rb
new file mode 100644
index 000000000..c2eb32b79
--- /dev/null
+++ b/db/migrate/20200731064236_create_account_metadata.rb
@@ -0,0 +1,10 @@
+class CreateAccountMetadata < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :account_metadata do |t|
+      t.references :account, null: false, unique: true, foreign_key: { on_delete: :cascade }
+      t.jsonb :fields, null: false, default: {}
+    end
+  end
+end
diff --git a/db/migrate/20200731135033_backfill_account_metadata.rb b/db/migrate/20200731135033_backfill_account_metadata.rb
new file mode 100644
index 000000000..2ddfa6081
--- /dev/null
+++ b/db/migrate/20200731135033_backfill_account_metadata.rb
@@ -0,0 +1,11 @@
+class BackfillAccountMetadata < ActiveRecord::Migration[5.2]
+  def up
+    safety_assured do
+      execute("INSERT INTO account_metadata (account_id) SELECT id FROM accounts WHERE domain IS NULL OR domain = ''")
+    end
+  end
+
+  def down
+    true
+  end
+end
diff --git a/db/migrate/20200731163700_create_destructing_statuses.rb b/db/migrate/20200731163700_create_destructing_statuses.rb
new file mode 100644
index 000000000..4923eb393
--- /dev/null
+++ b/db/migrate/20200731163700_create_destructing_statuses.rb
@@ -0,0 +1,11 @@
+class CreateDestructingStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :destructing_statuses do |t|
+      t.references :status, null: false, unique: true, foreign_key: { on_delete: :cascade }
+      t.datetime :after, null: false, index: { algorithm: :concurrently }
+      t.boolean :defederate_only, null: false, default: false
+    end
+  end
+end
diff --git a/db/migrate/20200731205913_create_queued_boosts.rb b/db/migrate/20200731205913_create_queued_boosts.rb
new file mode 100644
index 000000000..33ddbb966
--- /dev/null
+++ b/db/migrate/20200731205913_create_queued_boosts.rb
@@ -0,0 +1,10 @@
+class CreateQueuedBoosts < ActiveRecord::Migration[5.2]
+  def change
+    create_table :queued_boosts do |t|
+      t.references :account, null: false, foreign_key: { on_delete: :cascade }
+      t.references :status, null: false, foreign_key: { on_delete: :cascade }
+    end
+
+    add_index :queued_boosts, [:account_id, :status_id], unique: true
+  end
+end
diff --git a/db/migrate/20200731211100_create_publishing_delays.rb b/db/migrate/20200731211100_create_publishing_delays.rb
new file mode 100644
index 000000000..9561ca0b2
--- /dev/null
+++ b/db/migrate/20200731211100_create_publishing_delays.rb
@@ -0,0 +1,10 @@
+class CreatePublishingDelays < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :publishing_delays do |t|
+      t.references :status, null: false, unique: true, foreign_key: { on_delete: :cascade }
+      t.datetime :after, index: { algorithm: :concurrently }
+    end
+  end
+end
diff --git a/db/migrate/20200801210543_add_accounts_to_publishing_delays.rb b/db/migrate/20200801210543_add_accounts_to_publishing_delays.rb
new file mode 100644
index 000000000..21f29aab8
--- /dev/null
+++ b/db/migrate/20200801210543_add_accounts_to_publishing_delays.rb
@@ -0,0 +1,9 @@
+class AddAccountsToPublishingDelays < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    safety_assured do
+      add_reference :publishing_delays, :account, null: false, foreign_key: { on_delete: :cascade }, index: { algorithm: :concurrently }
+    end
+  end
+end
diff --git a/db/migrate/20200801220000_add_accounts_to_destructing_statuses.rb b/db/migrate/20200801220000_add_accounts_to_destructing_statuses.rb
new file mode 100644
index 000000000..42298b274
--- /dev/null
+++ b/db/migrate/20200801220000_add_accounts_to_destructing_statuses.rb
@@ -0,0 +1,9 @@
+class AddAccountsToDestructingStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    safety_assured do
+      add_reference :destructing_statuses, :account, null: false, foreign_key: { on_delete: :cascade }, index: { algorithm: :concurrently }
+    end
+  end
+end
diff --git a/db/migrate/20200811024642_update_status_indexes.rb b/db/migrate/20200811024642_update_status_indexes.rb
new file mode 100644
index 000000000..264f583a4
--- /dev/null
+++ b/db/migrate/20200811024642_update_status_indexes.rb
@@ -0,0 +1,23 @@
+class UpdateStatusIndexes < ActiveRecord::Migration[5.2]
+  def up
+    safety_assured do
+      add_index :statuses, ["id", "account_id"], name: "index_statuses_local", order: { id: :desc }, where: "((published = TRUE) AND (local = TRUE OR (uri IS NULL)) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((reply = FALSE) OR (in_reply_to_account_id = account_id)))"
+      add_index :statuses, ["id", "account_id"], name: "index_statuses_public", order: { id: :desc }, where: "((published = TRUE) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((reply = FALSE) OR (in_reply_to_account_id = account_id)))"
+      add_index :statuses, ["id", "account_id"], name: "index_statuses_local_reblogs", where: "(((local = TRUE) OR (uri IS NULL)) AND (statuses.reblog_of_id IS NOT NULL))"
+
+      remove_index :statuses, name: "index_statuses_local_20190824"
+      remove_index :statuses, name: "index_statuses_public_20200119"
+    end
+  end
+
+  def down
+    safety_assured do
+      add_index :statuses, ["id", "account_id"], name: "index_statuses_local_20190824", 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", 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"
+      remove_index :statuses, name: "index_statuses_local_reblogs"
+      remove_index :statuses, name: "index_statuses_public"
+    end
+  end
+end
diff --git a/db/migrate/20200816200108_add_root_to_conversations.rb b/db/migrate/20200816200108_add_root_to_conversations.rb
new file mode 100644
index 000000000..f45a3b476
--- /dev/null
+++ b/db/migrate/20200816200108_add_root_to_conversations.rb
@@ -0,0 +1,7 @@
+class AddRootToConversations < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :conversations, :root, :string, index: true
+    end
+  end
+end
diff --git a/db/migrate/20200816200239_backfill_root_to_conversations.rb b/db/migrate/20200816200239_backfill_root_to_conversations.rb
new file mode 100644
index 000000000..2056e0765
--- /dev/null
+++ b/db/migrate/20200816200239_backfill_root_to_conversations.rb
@@ -0,0 +1,19 @@
+class BackfillRootToConversations < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    Rails.logger.info("Adding URI to statuses without one...")
+    Status.where(uri: nil).or(Status.where(uri: '')).find_each do |status|
+      status.update(uri: ActivityPub::TagManager.instance.uri_for(status))
+    end
+
+    Rails.logger.info('Setting root of all conversations...')
+    safety_assured do
+      execute('UPDATE conversations SET root = s.uri FROM (SELECT conversation_id, uri FROM statuses WHERE NOT reply) AS s WHERE conversations.id = s.conversation_id')
+    end
+  end
+
+  def down
+    true
+  end
+end
diff --git a/db/migrate/20200817003033_add_defaults_to_conversations.rb b/db/migrate/20200817003033_add_defaults_to_conversations.rb
new file mode 100644
index 000000000..fc3c0ceee
--- /dev/null
+++ b/db/migrate/20200817003033_add_defaults_to_conversations.rb
@@ -0,0 +1,8 @@
+class AddDefaultsToConversations < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      change_column :conversations, :account_id, :bigint, default: nil
+      change_column :conversations, :root, :string, default: nil
+    end
+  end
+end
diff --git a/db/migrate/20200817003653_status_mute_account_id_bigint.rb b/db/migrate/20200817003653_status_mute_account_id_bigint.rb
new file mode 100644
index 000000000..e46d17845
--- /dev/null
+++ b/db/migrate/20200817003653_status_mute_account_id_bigint.rb
@@ -0,0 +1,7 @@
+class StatusMuteAccountIdBigint < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      change_column :status_mutes, :account_id, :bigint, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200817225525_add_footer_to_statuses.rb b/db/migrate/20200817225525_add_footer_to_statuses.rb
new file mode 100644
index 000000000..e85d225bc
--- /dev/null
+++ b/db/migrate/20200817225525_add_footer_to_statuses.rb
@@ -0,0 +1,5 @@
+class AddFooterToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    add_column :statuses, :footer, :text
+  end
+end
diff --git a/db/migrate/20200818040629_add_last_synced_at_to_accounts.rb b/db/migrate/20200818040629_add_last_synced_at_to_accounts.rb
new file mode 100644
index 000000000..0d64b5109
--- /dev/null
+++ b/db/migrate/20200818040629_add_last_synced_at_to_accounts.rb
@@ -0,0 +1,5 @@
+class AddLastSyncedAtToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    add_column :accounts, :last_synced_at, :datetime
+  end
+end
diff --git a/db/migrate/20200818160057_create_collection_items.rb b/db/migrate/20200818160057_create_collection_items.rb
new file mode 100644
index 000000000..88796ce0e
--- /dev/null
+++ b/db/migrate/20200818160057_create_collection_items.rb
@@ -0,0 +1,12 @@
+class CreateCollectionItems < ActiveRecord::Migration[5.2]
+  def change
+    create_table :collection_items do |t|
+      t.references :account, index: true, foreign_key: { on_delete: :cascade }
+      t.string :uri, null: false, index: { unique: true }
+      t.boolean :processed, null: false, default: false
+    end
+
+    add_index :collection_items, :id, name: 'unprocessed_collection_item_ids', where: 'processed = FALSE', order: { id: :desc }
+    add_index :collection_items, :account_id, name: 'unprocessed_collection_item_account_ids', where: 'processed = FALSE'
+  end
+end
diff --git a/db/migrate/20200818160106_create_collection_pages.rb b/db/migrate/20200818160106_create_collection_pages.rb
new file mode 100644
index 000000000..d00e1ca1c
--- /dev/null
+++ b/db/migrate/20200818160106_create_collection_pages.rb
@@ -0,0 +1,13 @@
+class CreateCollectionPages < ActiveRecord::Migration[5.2]
+  def change
+    create_table :collection_pages do |t|
+      t.references :account, index: true, foreign_key: { on_delete: :cascade }
+      t.string :uri, null: false, index: { unique: true }
+      t.string :next
+    end
+
+    add_index :collection_pages, :id, name: 'unprocessed_collection_page_ids', where: 'next IS NULL'
+    add_index :collection_pages, :account_id, name: 'unprocessed_collection_page_account_ids', where: 'next IS NULL'
+    add_index :collection_pages, :uri, name: 'unprocessed_collection_pages_uris', where: 'next IS NULL'
+  end
+end
diff --git a/db/migrate/20200821051721_add_retries_to_collection_items.rb b/db/migrate/20200821051721_add_retries_to_collection_items.rb
new file mode 100644
index 000000000..9cee437d9
--- /dev/null
+++ b/db/migrate/20200821051721_add_retries_to_collection_items.rb
@@ -0,0 +1,5 @@
+class AddRetriesToCollectionItems < ActiveRecord::Migration[5.2]
+  def change
+    add_column :collection_items, :retries, :integer, limit: 1, default: 0, null: false
+  end
+end
diff --git a/db/migrate/20200822054516_remove_public_column_from_conversations.rb b/db/migrate/20200822054516_remove_public_column_from_conversations.rb
new file mode 100644
index 000000000..e015f3f63
--- /dev/null
+++ b/db/migrate/20200822054516_remove_public_column_from_conversations.rb
@@ -0,0 +1,7 @@
+class RemovePublicColumnFromConversations < ActiveRecord::Migration[5.2]
+  def change
+    def safety_assured
+      remove_column :conversations, :public
+    end
+  end
+end
diff --git a/db/migrate/20200823002835_unlink_blocked_replies.rb b/db/migrate/20200823002835_unlink_blocked_replies.rb
new file mode 100644
index 000000000..6968fc93f
--- /dev/null
+++ b/db/migrate/20200823002835_unlink_blocked_replies.rb
@@ -0,0 +1,28 @@
+class UnlinkBlockedReplies < ActiveRecord::Migration[5.2]
+  def up
+    Block.find_each do |block|
+      next if block.account.nil? || block.target_account.nil?
+
+      unlink_replies!(block.account, block.target_account)
+      unlink_mentions!(block.account, block.target_account)
+    end
+  end
+
+  def down
+    nil
+  end
+
+  private
+
+  def unlink_replies!(account, target_account)
+    target_account.statuses.where(in_reply_to_account_id: account.id)
+      .or(account.statuses.where(in_reply_to_account_id: target_account.id))
+      .in_batches.update_all(in_reply_to_account_id: nil)
+  end
+
+  def unlink_mentions!(account, target_account)
+    account.mentions.where(account_id: target_account.id)
+      .or(target_account.mentions.where(account_id: account.id))
+      .in_batches.destroy_all
+  end
+end
diff --git a/db/migrate/20200826125821_add_username_and_nospam_to_users.rb b/db/migrate/20200826125821_add_username_and_nospam_to_users.rb
new file mode 100644
index 000000000..9a964b980
--- /dev/null
+++ b/db/migrate/20200826125821_add_username_and_nospam_to_users.rb
@@ -0,0 +1,6 @@
+class AddUsernameAndNospamToUsers < ActiveRecord::Migration[5.2]
+  def change
+    add_column :users, :username, :string
+    add_column :users, :kobold, :string
+  end
+end
diff --git a/db/migrate/20200901035527_add_sticky_to_account_domain_permissions.rb b/db/migrate/20200901035527_add_sticky_to_account_domain_permissions.rb
new file mode 100644
index 000000000..2acfce329
--- /dev/null
+++ b/db/migrate/20200901035527_add_sticky_to_account_domain_permissions.rb
@@ -0,0 +1,7 @@
+class AddStickyToAccountDomainPermissions < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :account_domain_permissions, :sticky, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200901183004_backfill_user_username.rb b/db/migrate/20200901183004_backfill_user_username.rb
new file mode 100644
index 000000000..e206aaae8
--- /dev/null
+++ b/db/migrate/20200901183004_backfill_user_username.rb
@@ -0,0 +1,11 @@
+class BackfillUserUsername < ActiveRecord::Migration[5.2]
+  def up
+    User.find_each do |user|
+      user.update!(username: user.account.username)
+    end
+  end
+
+  def down
+    nil
+  end
+end
diff --git a/db/migrate/20200904002209_add_expires_at_to_statuses.rb b/db/migrate/20200904002209_add_expires_at_to_statuses.rb
new file mode 100644
index 000000000..53049b159
--- /dev/null
+++ b/db/migrate/20200904002209_add_expires_at_to_statuses.rb
@@ -0,0 +1,8 @@
+class AddExpiresAtToStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_column :statuses, :expires_at, :datetime
+    add_index :statuses, :expires_at, algorithm: :concurrently, where: 'expires_at IS NOT NULL'
+  end
+end
diff --git a/db/migrate/20200904004330_add_publish_at_to_statuses.rb b/db/migrate/20200904004330_add_publish_at_to_statuses.rb
new file mode 100644
index 000000000..35a32eb0e
--- /dev/null
+++ b/db/migrate/20200904004330_add_publish_at_to_statuses.rb
@@ -0,0 +1,8 @@
+class AddPublishAtToStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_column :statuses, :publish_at, :datetime
+    add_index :statuses, :publish_at, algorithm: :concurrently, where: 'publish_at IS NOT NULL'
+  end
+end
diff --git a/db/migrate/20200904005553_drop_publishing_delay.rb b/db/migrate/20200904005553_drop_publishing_delay.rb
new file mode 100644
index 000000000..509e591c7
--- /dev/null
+++ b/db/migrate/20200904005553_drop_publishing_delay.rb
@@ -0,0 +1,5 @@
+class DropPublishingDelay < ActiveRecord::Migration[5.2]
+  def change
+    drop_table :publishing_delays
+  end
+end
diff --git a/db/migrate/20200904005706_drop_destructing_status.rb b/db/migrate/20200904005706_drop_destructing_status.rb
new file mode 100644
index 000000000..39885aabd
--- /dev/null
+++ b/db/migrate/20200904005706_drop_destructing_status.rb
@@ -0,0 +1,5 @@
+class DropDestructingStatus < ActiveRecord::Migration[5.2]
+  def change
+    drop_table :destructing_statuses
+  end
+end
diff --git a/db/migrate/20200904184045_add_originally_local_only_to_statuses.rb b/db/migrate/20200904184045_add_originally_local_only_to_statuses.rb
new file mode 100644
index 000000000..abff57b45
--- /dev/null
+++ b/db/migrate/20200904184045_add_originally_local_only_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddOriginallyLocalOnlyToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :statuses, :originally_local_only, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200904184155_backfill_originally_local_only.rb b/db/migrate/20200904184155_backfill_originally_local_only.rb
new file mode 100644
index 000000000..d87609db9
--- /dev/null
+++ b/db/migrate/20200904184155_backfill_originally_local_only.rb
@@ -0,0 +1,14 @@
+class BackfillOriginallyLocalOnly < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    safety_assured do
+      execute('UPDATE statuses SET originally_local_only = false WHERE originally_local_only IS NULL')
+      execute('UPDATE statuses SET originally_local_only = true WHERE local_only')
+    end
+  end
+
+  def down
+    nil
+  end
+end
diff --git a/db/migrate/20200904200803_backfill_default_false_to_local_only.rb b/db/migrate/20200904200803_backfill_default_false_to_local_only.rb
new file mode 100644
index 000000000..236a01c14
--- /dev/null
+++ b/db/migrate/20200904200803_backfill_default_false_to_local_only.rb
@@ -0,0 +1,13 @@
+class BackfillDefaultFalseToLocalOnly < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    safety_assured do
+      execute('UPDATE statuses SET local_only = false WHERE local_only IS NULL')
+    end
+  end
+
+  def down
+    nil
+  end
+end
diff --git a/db/migrate/20200904201028_add_default_false_to_local_only.rb b/db/migrate/20200904201028_add_default_false_to_local_only.rb
new file mode 100644
index 000000000..7f9bb99d4
--- /dev/null
+++ b/db/migrate/20200904201028_add_default_false_to_local_only.rb
@@ -0,0 +1,7 @@
+class AddDefaultFalseToLocalOnly < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      change_column :statuses, :local_only, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200907195410_add_index_to_users_username.rb b/db/migrate/20200907195410_add_index_to_users_username.rb
new file mode 100644
index 000000000..06452e0dd
--- /dev/null
+++ b/db/migrate/20200907195410_add_index_to_users_username.rb
@@ -0,0 +1,8 @@
+class AddIndexToUsersUsername < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :users, :username, unique: true, algorithm: :concurrently
+    add_index :users, 'lower(username)', unique: true, algorithm: :concurrently, name: 'index_on_users_username_lowercase'
+  end
+end
diff --git a/db/migrate/20200919234917_add_account_to_custom_emoji.rb b/db/migrate/20200919234917_add_account_to_custom_emoji.rb
new file mode 100644
index 000000000..b4466ee30
--- /dev/null
+++ b/db/migrate/20200919234917_add_account_to_custom_emoji.rb
@@ -0,0 +1,7 @@
+class AddAccountToCustomEmoji < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_reference :custom_emojis, :account, foreign_key: { on_delete: :nullify }, index: true
+    end
+  end
+end
diff --git a/db/migrate/20200920084007_backfill_custom_emoji_ownership.rb b/db/migrate/20200920084007_backfill_custom_emoji_ownership.rb
new file mode 100644
index 000000000..1542bdb5e
--- /dev/null
+++ b/db/migrate/20200920084007_backfill_custom_emoji_ownership.rb
@@ -0,0 +1,12 @@
+class BackfillCustomEmojiOwnership < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    site_contact = Account.site_contact
+    CustomEmoji.local.in_batches.update_all(account_id: site_contact.id)
+  end
+
+  def down
+    nil
+  end
+end
diff --git a/db/migrate/20200921024447_add_curated_to_statuses.rb b/db/migrate/20200921024447_add_curated_to_statuses.rb
new file mode 100644
index 000000000..05558ded3
--- /dev/null
+++ b/db/migrate/20200921024447_add_curated_to_statuses.rb
@@ -0,0 +1,7 @@
+class AddCuratedToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :statuses, :curated, :boolean, default: false, null: false
+    end
+  end
+end
diff --git a/db/migrate/20200921030158_backfill_curated_statuses.rb b/db/migrate/20200921030158_backfill_curated_statuses.rb
new file mode 100644
index 000000000..f9bf32afb
--- /dev/null
+++ b/db/migrate/20200921030158_backfill_curated_statuses.rb
@@ -0,0 +1,12 @@
+class BackfillCuratedStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    Status.with_public_visibility.joins(:status_stat).where('favourites_count != 0 OR reblogs_count != 0').in_batches.update_all(curated: true)
+    Status.with_public_visibility.where(curated: false).left_outer_joins(:bookmarks).where.not(bookmarks: { status_id: nil }).in_batches.update_all(curated: true)
+  end
+
+  def down
+    nil
+  end
+end
diff --git a/db/migrate/20200923000000_update_status_indexes_202009.rb b/db/migrate/20200923000000_update_status_indexes_202009.rb
new file mode 100644
index 000000000..9b6f58d3c
--- /dev/null
+++ b/db/migrate/20200923000000_update_status_indexes_202009.rb
@@ -0,0 +1,25 @@
+class UpdateStatusIndexes202009 < ActiveRecord::Migration[5.2]
+  def up
+    safety_assured do
+      remove_index :statuses, name: "index_statuses_local"
+      remove_index :statuses, name: "index_statuses_local_reblogs"
+      remove_index :statuses, name: "index_statuses_public"
+
+      add_index :statuses, :id, name: "index_statuses_local", order: { id: :desc }, where: "(published = TRUE) AND (local = TRUE OR (uri IS NULL)) AND (deleted_at IS NULL)"
+      add_index :statuses, :id, name: "index_statuses_curated", order: { id: :desc }, where: "(published = TRUE) AND (deleted_at IS NULL) AND (curated = TRUE)"
+      add_index :statuses, :id, name: "index_statuses_public", order: { id: :desc }, where: "(published = TRUE) AND (deleted_at IS NULL)"
+    end
+  end
+
+  def down
+    safety_assured do
+      remove_index :statuses, name: "index_statuses_local"
+      remove_index :statuses, name: "index_statuses_curated"
+      remove_index :statuses, name: "index_statuses_public"
+
+      add_index :statuses, ["id", "account_id"], name: "index_statuses_local", order: { id: :desc }, where: "((published = TRUE) AND (local = TRUE OR (uri IS NULL)) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((reply = FALSE) OR (in_reply_to_account_id = account_id)))"
+      add_index :statuses, ["id", "account_id"], name: "index_statuses_local_reblogs", where: "(((local = TRUE) OR (uri IS NULL)) AND (statuses.reblog_of_id IS NOT NULL))"
+      add_index :statuses, ["id", "account_id"], name: "index_statuses_public", order: { id: :desc }, where: "((published = TRUE) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((reply = FALSE) OR (in_reply_to_account_id = account_id)))"
+    end
+  end
+end
diff --git a/db/migrate/20200923000001_remove_conversation_account.rb b/db/migrate/20200923000001_remove_conversation_account.rb
new file mode 100644
index 000000000..1b61d41bf
--- /dev/null
+++ b/db/migrate/20200923000001_remove_conversation_account.rb
@@ -0,0 +1,7 @@
+class RemoveConversationAccount < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      remove_column :conversations, :account_id
+    end
+  end
+end
diff --git a/db/migrate/20200923000002_remove_semiprivate_flag.rb b/db/migrate/20200923000002_remove_semiprivate_flag.rb
new file mode 100644
index 000000000..cd732c616
--- /dev/null
+++ b/db/migrate/20200923000002_remove_semiprivate_flag.rb
@@ -0,0 +1,7 @@
+class RemoveSemiprivateFlag < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      remove_column :statuses, :semiprivate
+    end
+  end
+end
diff --git a/db/migrate/20200923000003_add_reblogs_flag_to_lists.rb b/db/migrate/20200923000003_add_reblogs_flag_to_lists.rb
new file mode 100644
index 000000000..bb6bcc6c2
--- /dev/null
+++ b/db/migrate/20200923000003_add_reblogs_flag_to_lists.rb
@@ -0,0 +1,8 @@
+class AddReblogsFlagToLists < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      add_column :lists, :reblogs, :boolean, default: false, null: false
+      add_index :lists, :id, name: :lists_reblog_feeds, where: '(reblogs = TRUE)'
+    end
+  end
+end
diff --git a/db/migrate/20200925035221_drop_conversations_public.rb b/db/migrate/20200925035221_drop_conversations_public.rb
new file mode 100644
index 000000000..e09f6014a
--- /dev/null
+++ b/db/migrate/20200925035221_drop_conversations_public.rb
@@ -0,0 +1,7 @@
+class DropConversationsPublic < ActiveRecord::Migration[5.2]
+  def change
+    safety_assured do
+      remove_column :conversations, :public
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6d6f97f0a..323851b10 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -51,6 +51,17 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.index ["account_id", "domain"], name: "index_account_domain_blocks_on_account_id_and_domain", unique: true
   end
 
+  create_table "account_domain_permissions", force: :cascade do |t|
+    t.bigint "account_id", null: false
+    t.string "domain", default: "", null: false
+    t.integer "visibility", default: 0, null: false
+    t.boolean "sticky", default: false, null: false
+    t.index ["account_id", "domain"], name: "index_account_domain_permissions_on_account_id_and_domain", unique: true
+    t.index ["account_id"], name: "index_account_domain_permissions_on_account_id"
+    t.index ["domain"], name: "index_account_domain_permissions_on_domain"
+    t.index ["visibility"], name: "index_account_domain_permissions_on_visibility"
+  end
+
   create_table "account_identity_proofs", force: :cascade do |t|
     t.bigint "account_id"
     t.string "provider", default: "", null: false
@@ -63,6 +74,12 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.index ["account_id", "provider", "provider_username"], name: "index_account_proofs_on_account_and_provider_and_username", unique: true
   end
 
+  create_table "account_metadata", force: :cascade do |t|
+    t.bigint "account_id", null: false
+    t.jsonb "fields", default: {}, null: false
+    t.index ["account_id"], name: "index_account_metadata_on_account_id"
+  end
+
   create_table "account_migrations", force: :cascade do |t|
     t.bigint "account_id"
     t.string "acct", default: "", null: false
@@ -189,6 +206,12 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.integer "avatar_storage_schema_version"
     t.integer "header_storage_schema_version"
     t.string "devices_url"
+    t.boolean "require_dereference", default: false, null: false
+    t.boolean "show_replies", default: true, null: false
+    t.boolean "show_unlisted", default: true, null: false
+    t.boolean "private", default: false, null: false
+    t.boolean "require_auth", default: false, null: false
+    t.datetime "last_synced_at"
     t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
     t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
     t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
@@ -279,9 +302,32 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.index ["status_id"], name: "index_bookmarks_on_status_id"
   end
 
+  create_table "collection_items", force: :cascade do |t|
+    t.bigint "account_id"
+    t.string "uri", null: false
+    t.boolean "processed", default: false, null: false
+    t.integer "retries", limit: 2, default: 0, null: false
+    t.index ["account_id"], name: "index_collection_items_on_account_id"
+    t.index ["account_id"], name: "unprocessed_collection_item_account_ids", where: "(processed = false)"
+    t.index ["id"], name: "unprocessed_collection_item_ids", order: :desc, where: "(processed = false)"
+    t.index ["uri"], name: "index_collection_items_on_uri", unique: true
+  end
+
+  create_table "collection_pages", force: :cascade do |t|
+    t.bigint "account_id"
+    t.string "uri", null: false
+    t.string "next"
+    t.index ["account_id"], name: "index_collection_pages_on_account_id"
+    t.index ["account_id"], name: "unprocessed_collection_page_account_ids", where: "(next IS NULL)"
+    t.index ["id"], name: "unprocessed_collection_page_ids", where: "(next IS NULL)"
+    t.index ["uri"], name: "index_collection_pages_on_uri", unique: true
+    t.index ["uri"], name: "unprocessed_collection_pages_uris", where: "(next IS NULL)"
+  end
+
   create_table "conversation_mutes", force: :cascade do |t|
     t.bigint "conversation_id", null: false
     t.bigint "account_id", null: false
+    t.boolean "hidden", default: false, null: false
     t.index ["account_id", "conversation_id"], name: "index_conversation_mutes_on_account_id_and_conversation_id", unique: true
   end
 
@@ -289,6 +335,7 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.string "uri"
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.string "root"
     t.index ["uri"], name: "index_conversations_on_uri", unique: true
   end
 
@@ -314,6 +361,8 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.boolean "visible_in_picker", default: true, null: false
     t.bigint "category_id"
     t.integer "image_storage_schema_version"
+    t.bigint "account_id"
+    t.index ["account_id"], name: "index_custom_emojis_on_account_id"
     t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
   end
 
@@ -346,6 +395,7 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.string "domain", default: "", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.boolean "hidden", default: false, null: false
     t.index ["domain"], name: "index_domain_allows_on_domain", unique: true
   end
 
@@ -449,6 +499,14 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.boolean "overwrite", default: false, null: false
   end
 
+  create_table "inline_media_attachments", force: :cascade do |t|
+    t.bigint "status_id"
+    t.bigint "media_attachment_id"
+    t.index ["media_attachment_id"], name: "index_inline_media_attachments_on_media_attachment_id"
+    t.index ["status_id", "media_attachment_id"], name: "uniq_index_on_status_and_attachment", unique: true
+    t.index ["status_id"], name: "index_inline_media_attachments_on_status_id"
+  end
+
   create_table "invites", force: :cascade do |t|
     t.bigint "user_id", null: false
     t.string "code", default: "", null: false
@@ -487,7 +545,9 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.integer "replies_policy", default: 0, null: false
+    t.boolean "reblogs", default: false, null: false
     t.index ["account_id"], name: "index_lists_on_account_id"
+    t.index ["id"], name: "lists_reblog_feeds", where: "(reblogs = true)"
   end
 
   create_table "markers", force: :cascade do |t|
@@ -523,6 +583,7 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.integer "thumbnail_file_size"
     t.datetime "thumbnail_updated_at"
     t.string "thumbnail_remote_url"
+    t.boolean "inline", default: false, null: false
     t.index ["account_id"], name: "index_media_attachments_on_account_id"
     t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id"
     t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true
@@ -546,6 +607,7 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.bigint "account_id", null: false
     t.bigint "target_account_id", null: false
     t.datetime "expires_at"
+    t.boolean "timelines_only", default: false, null: false
     t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
     t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
   end
@@ -686,6 +748,14 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
   end
 
+  create_table "queued_boosts", force: :cascade do |t|
+    t.bigint "account_id", null: false
+    t.bigint "status_id", null: false
+    t.index ["account_id", "status_id"], name: "index_queued_boosts_on_account_id_and_status_id", unique: true
+    t.index ["account_id"], name: "index_queued_boosts_on_account_id"
+    t.index ["status_id"], name: "index_queued_boosts_on_status_id"
+  end
+
   create_table "relays", force: :cascade do |t|
     t.string "inbox_url", default: "", null: false
     t.string "follow_activity_id"
@@ -763,6 +833,24 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.index ["var"], name: "index_site_uploads_on_var", unique: true
   end
 
+  create_table "status_domain_permissions", force: :cascade do |t|
+    t.bigint "status_id", null: false
+    t.string "domain", default: "", null: false
+    t.integer "visibility", default: 0, null: false
+    t.index ["domain"], name: "index_status_domain_permissions_on_domain"
+    t.index ["status_id", "domain"], name: "index_status_domain_permissions_on_status_id_and_domain", unique: true
+    t.index ["status_id"], name: "index_status_domain_permissions_on_status_id"
+    t.index ["visibility"], name: "index_status_domain_permissions_on_visibility"
+  end
+
+  create_table "status_mutes", force: :cascade do |t|
+    t.bigint "account_id", null: false
+    t.bigint "status_id", null: false
+    t.index ["account_id", "status_id"], name: "index_status_mutes_on_account_id_and_status_id", unique: true
+    t.index ["account_id"], name: "index_status_mutes_on_account_id"
+    t.index ["status_id"], name: "index_status_mutes_on_status_id"
+  end
+
   create_table "status_pins", force: :cascade do |t|
     t.bigint "account_id", null: false
     t.bigint "status_id", null: false
@@ -799,17 +887,34 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.bigint "account_id", null: false
     t.bigint "application_id"
     t.bigint "in_reply_to_account_id"
-    t.boolean "local_only"
+    t.boolean "local_only", default: false, null: false
     t.bigint "poll_id"
     t.string "content_type"
     t.datetime "deleted_at"
+    t.integer "edited", default: 0, null: false
+    t.integer "nest_level", limit: 2, default: 0, null: false
+    t.boolean "published", default: true, null: false
+    t.text "title"
+    t.text "original_text"
+    t.text "footer"
+    t.datetime "expires_at"
+    t.datetime "publish_at"
+    t.boolean "originally_local_only", default: false, null: false
+    t.boolean "curated", default: false, null: false
     t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
-    t.index ["id", "account_id"], name: "index_statuses_local_20190824", 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)))"
-    t.index ["id", "account_id"], name: "index_statuses_public_20200119", 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)))"
+    t.index ["account_id", "id"], name: "index_unpublished_statuses", order: { id: :desc }, where: "((deleted_at IS NULL) AND (published = false))"
+    t.index ["conversation_id"], name: "index_statuses_on_conversation_id", where: "(deleted_at IS NULL)"
+    t.index ["expires_at"], name: "index_statuses_on_expires_at", where: "(expires_at IS NOT NULL)"
+    t.index ["id", "account_id"], name: "index_statuses_on_id_and_account_id"
+    t.index ["id"], name: "index_statuses_curated", order: :desc, where: "((published = true) AND (deleted_at IS NULL) AND (curated = true))"
+    t.index ["id"], name: "index_statuses_local", order: :desc, where: "((published = true) AND ((local = true) OR (uri IS NULL)) AND (deleted_at IS NULL))"
+    t.index ["id"], name: "index_statuses_public", order: :desc, where: "((published = true) AND (deleted_at IS NULL))"
     t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
     t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
+    t.index ["publish_at"], name: "index_statuses_on_publish_at", where: "(publish_at IS NOT NULL)"
     t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
     t.index ["uri"], name: "index_statuses_on_uri", unique: true
+    t.index ["visibility"], name: "index_statuses_on_visibility", where: "(deleted_at IS NULL)"
   end
 
   create_table "statuses_tags", id: false, force: :cascade do |t|
@@ -902,14 +1007,18 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
     t.boolean "approved", default: true, null: false
     t.string "sign_in_token"
     t.datetime "sign_in_token_sent_at"
+    t.string "username"
+    t.string "kobold"
     t.string "webauthn_id"
     t.inet "sign_up_ip"
+    t.index "lower((username)::text)", name: "index_on_users_username_lowercase", unique: true
     t.index ["account_id"], name: "index_users_on_account_id"
     t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
     t.index ["created_by_application_id"], name: "index_users_on_created_by_application_id"
     t.index ["email"], name: "index_users_on_email", unique: true
     t.index ["remember_token"], name: "index_users_on_remember_token", unique: true
     t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+    t.index ["username"], name: "index_users_on_username", unique: true
   end
 
   create_table "web_push_subscriptions", force: :cascade do |t|
@@ -950,7 +1059,9 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
   add_foreign_key "account_conversations", "conversations", on_delete: :cascade
   add_foreign_key "account_deletion_requests", "accounts", on_delete: :cascade
   add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
+  add_foreign_key "account_domain_permissions", "accounts", on_delete: :cascade
   add_foreign_key "account_identity_proofs", "accounts", on_delete: :cascade
+  add_foreign_key "account_metadata", "accounts", on_delete: :cascade
   add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
   add_foreign_key "account_migrations", "accounts", on_delete: :cascade
   add_foreign_key "account_moderation_notes", "accounts"
@@ -975,8 +1086,11 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
   add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
   add_foreign_key "bookmarks", "accounts", on_delete: :cascade
   add_foreign_key "bookmarks", "statuses", on_delete: :cascade
+  add_foreign_key "collection_items", "accounts", on_delete: :cascade
+  add_foreign_key "collection_pages", "accounts", on_delete: :cascade
   add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
   add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
+  add_foreign_key "custom_emojis", "accounts", on_delete: :nullify
   add_foreign_key "custom_filters", "accounts", on_delete: :cascade
   add_foreign_key "devices", "accounts", on_delete: :cascade
   add_foreign_key "devices", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
@@ -993,6 +1107,8 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
   add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
   add_foreign_key "identities", "users", name: "fk_bea040f377", on_delete: :cascade
   add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
+  add_foreign_key "inline_media_attachments", "media_attachments", on_delete: :cascade
+  add_foreign_key "inline_media_attachments", "statuses", on_delete: :cascade
   add_foreign_key "invites", "users", on_delete: :cascade
   add_foreign_key "list_accounts", "accounts", on_delete: :cascade
   add_foreign_key "list_accounts", "follows", on_delete: :cascade
@@ -1018,6 +1134,8 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
   add_foreign_key "poll_votes", "polls", on_delete: :cascade
   add_foreign_key "polls", "accounts", on_delete: :cascade
   add_foreign_key "polls", "statuses", on_delete: :cascade
+  add_foreign_key "queued_boosts", "accounts", on_delete: :cascade
+  add_foreign_key "queued_boosts", "statuses", on_delete: :cascade
   add_foreign_key "report_notes", "accounts", on_delete: :cascade
   add_foreign_key "report_notes", "reports", on_delete: :cascade
   add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify
@@ -1027,6 +1145,7 @@ ActiveRecord::Schema.define(version: 2020_10_08_220312) do
   add_foreign_key "scheduled_statuses", "accounts", on_delete: :cascade
   add_foreign_key "session_activations", "oauth_access_tokens", column: "access_token_id", name: "fk_957e5bda89", on_delete: :cascade
   add_foreign_key "session_activations", "users", name: "fk_e5fda67334", on_delete: :cascade
+  add_foreign_key "status_domain_permissions", "statuses", on_delete: :cascade
   add_foreign_key "status_pins", "accounts", name: "fk_d4cb435b62", on_delete: :cascade
   add_foreign_key "status_pins", "statuses", on_delete: :cascade
   add_foreign_key "status_stats", "statuses", on_delete: :cascade