about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorStarfall <root@starfall.blue>2020-02-04 17:44:29 -0600
committerStarfall <root@starfall.blue>2020-02-04 17:44:29 -0600
commit6d24d3bcb84abd04f31da95f97f6d60ef0afdc00 (patch)
treee7c38251a9e92bdf3a464b4aa7f1880aa5139bf0 /db
parentc0c9529df269816f52915a9802e5e30fbce9576b (diff)
parent885e9227c6e8e1ce5e4a5625d5126ba76dce2c00 (diff)
Merge branch 'glitch'
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170711225116_fix_null_booleans.rb20
-rw-r--r--db/migrate/20170918125918_ids_to_bigints.rb28
-rw-r--r--db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb6
-rw-r--r--db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb4
-rw-r--r--db/migrate/20180206000000_change_user_id_nonnullable.rb6
-rw-r--r--db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb10
-rw-r--r--db/migrate/20180528141303_fix_accounts_unique_index.rb28
-rw-r--r--db/migrate/20181024224956_migrate_account_conversations.rb22
-rw-r--r--db/migrate/20191031163205_change_list_account_follow_nullable.rb4
-rw-r--r--db/migrate/20191218153258_create_announcements.rb16
-rw-r--r--db/migrate/20200113125135_create_announcement_mutes.rb12
-rw-r--r--db/migrate/20200114113335_create_announcement_reactions.rb15
-rw-r--r--db/migrate/20200119112504_add_public_index_to_statuses.rb11
-rw-r--r--db/migrate/20200126203551_add_published_at_to_announcements.rb5
-rw-r--r--db/schema.rb45
15 files changed, 175 insertions, 57 deletions
diff --git a/db/migrate/20170711225116_fix_null_booleans.rb b/db/migrate/20170711225116_fix_null_booleans.rb
index 5b319471d..aabb81f21 100644
--- a/db/migrate/20170711225116_fix_null_booleans.rb
+++ b/db/migrate/20170711225116_fix_null_booleans.rb
@@ -1,17 +1,19 @@
 class FixNullBooleans < ActiveRecord::Migration[5.1]
   def change
-    change_column_default :domain_blocks, :reject_media, false
-    change_column_null :domain_blocks, :reject_media, false, false
+    safety_assured do
+      change_column_default :domain_blocks, :reject_media, false
+      change_column_null :domain_blocks, :reject_media, false, false
 
-    change_column_default :imports, :approved, false
-    change_column_null :imports, :approved, false, false
+      change_column_default :imports, :approved, false
+      change_column_null :imports, :approved, false, false
 
-    change_column_null :statuses, :sensitive, false, false
-    change_column_null :statuses, :reply, false, false
+      change_column_null :statuses, :sensitive, false, false
+      change_column_null :statuses, :reply, false, false
 
-    change_column_null :users, :admin, false, false
+      change_column_null :users, :admin, false, false
 
-    change_column_default :users, :otp_required_for_login, false
-    change_column_null :users, :otp_required_for_login, false, false
+      change_column_default :users, :otp_required_for_login, false
+      change_column_null :users, :otp_required_for_login, false, false
+    end
   end
 end
diff --git a/db/migrate/20170918125918_ids_to_bigints.rb b/db/migrate/20170918125918_ids_to_bigints.rb
index 8e19468db..bcb2e9eca 100644
--- a/db/migrate/20170918125918_ids_to_bigints.rb
+++ b/db/migrate/20170918125918_ids_to_bigints.rb
@@ -70,20 +70,22 @@ class IdsToBigints < ActiveRecord::Migration[5.1]
     included_columns << [:deprecated_preview_cards, :id] if table_exists?(:deprecated_preview_cards)
 
     # Print out a warning that this will probably take a while.
-    say ''
-    say 'WARNING: This migration may take a *long* time for large instances'
-    say 'It will *not* lock tables for any significant time, but it may run'
-    say 'for a very long time. We will pause for 10 seconds to allow you to'
-    say 'interrupt this migration if you are not ready.'
-    say ''
-    say 'This migration has some sections that can be safely interrupted'
-    say 'and restarted later, and will tell you when those are occurring.'
-    say ''
-    say 'For more information, see https://github.com/tootsuite/mastodon/pull/5088'
+    if $stdout.isatty
+      say ''
+      say 'WARNING: This migration may take a *long* time for large instances'
+      say 'It will *not* lock tables for any significant time, but it may run'
+      say 'for a very long time. We will pause for 10 seconds to allow you to'
+      say 'interrupt this migration if you are not ready.'
+      say ''
+      say 'This migration has some sections that can be safely interrupted'
+      say 'and restarted later, and will tell you when those are occurring.'
+      say ''
+      say 'For more information, see https://github.com/tootsuite/mastodon/pull/5088'
 
-    10.downto(1) do |i|
-      say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
-      sleep 1
+      10.downto(1) do |i|
+        say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
+        sleep 1
+      end
     end
 
     tables = included_columns.map(&:first).uniq
diff --git a/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb b/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
index 747e5a826..1d7a0086c 100644
--- a/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
+++ b/db/migrate/20171010025614_change_accounts_nonnullable_in_account_moderation_notes.rb
@@ -1,6 +1,8 @@
 class ChangeAccountsNonnullableInAccountModerationNotes < ActiveRecord::Migration[5.1]
   def change
-    change_column_null :account_moderation_notes, :account_id, false
-    change_column_null :account_moderation_notes, :target_account_id, false
+    safety_assured do
+      change_column_null :account_moderation_notes, :account_id, false
+      change_column_null :account_moderation_notes, :target_account_id, false
+    end
   end
 end
diff --git a/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb b/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb
index 3369e3b9e..ac86c9e77 100644
--- a/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb
+++ b/db/migrate/20171201000000_change_account_id_nonnullable_in_lists.rb
@@ -1,5 +1,7 @@
 class ChangeAccountIdNonnullableInLists < ActiveRecord::Migration[5.1]
   def change
-    change_column_null :lists, :account_id, false
+    safety_assured do
+      change_column_null :lists, :account_id, false
+    end
   end
 end
diff --git a/db/migrate/20180206000000_change_user_id_nonnullable.rb b/db/migrate/20180206000000_change_user_id_nonnullable.rb
index 4eecb6154..2d2cf20d3 100644
--- a/db/migrate/20180206000000_change_user_id_nonnullable.rb
+++ b/db/migrate/20180206000000_change_user_id_nonnullable.rb
@@ -1,6 +1,8 @@
 class ChangeUserIdNonnullable < ActiveRecord::Migration[5.1]
   def change
-    change_column_null :invites, :user_id, false
-    change_column_null :web_settings, :user_id, false
+    safety_assured do
+      change_column_null :invites, :user_id, false
+      change_column_null :web_settings, :user_id, false
+    end
   end
 end
diff --git a/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb b/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb
index 05ffd0501..dba789207 100644
--- a/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb
+++ b/db/migrate/20180310000000_change_columns_in_notifications_nonnullable.rb
@@ -1,8 +1,10 @@
 class ChangeColumnsInNotificationsNonnullable < ActiveRecord::Migration[5.1]
   def change
-    change_column_null :notifications, :activity_id, false
-    change_column_null :notifications, :activity_type, false
-    change_column_null :notifications, :account_id, false
-    change_column_null :notifications, :from_account_id, false
+    safety_assured do
+      change_column_null :notifications, :activity_id, false
+      change_column_null :notifications, :activity_type, false
+      change_column_null :notifications, :account_id, false
+      change_column_null :notifications, :from_account_id, false
+    end
   end
 end
diff --git a/db/migrate/20180528141303_fix_accounts_unique_index.rb b/db/migrate/20180528141303_fix_accounts_unique_index.rb
index bbbf28d81..5d7b3c463 100644
--- a/db/migrate/20180528141303_fix_accounts_unique_index.rb
+++ b/db/migrate/20180528141303_fix_accounts_unique_index.rb
@@ -20,19 +20,21 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
   disable_ddl_transaction!
 
   def up
-    say ''
-    say 'WARNING: This migration may take a *long* time for large instances'
-    say 'It will *not* lock tables for any significant time, but it may run'
-    say 'for a very long time. We will pause for 10 seconds to allow you to'
-    say 'interrupt this migration if you are not ready.'
-    say ''
-    say 'This migration will irreversibly delete user accounts with duplicate'
-    say 'usernames. You may use the `rake mastodon:maintenance:find_duplicate_usernames`'
-    say 'task to manually deal with such accounts before running this migration.'
-
-    10.downto(1) do |i|
-      say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
-      sleep 1
+    if $stdout.isatty
+      say ''
+      say 'WARNING: This migration may take a *long* time for large instances'
+      say 'It will *not* lock tables for any significant time, but it may run'
+      say 'for a very long time. We will pause for 10 seconds to allow you to'
+      say 'interrupt this migration if you are not ready.'
+      say ''
+      say 'This migration will irreversibly delete user accounts with duplicate'
+      say 'usernames. You may use the `rake mastodon:maintenance:find_duplicate_usernames`'
+      say 'task to manually deal with such accounts before running this migration.'
+
+      10.downto(1) do |i|
+        say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
+        sleep 1
+      end
     end
 
     duplicates = Account.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM accounts GROUP BY lower(username), lower(domain) HAVING count(*) > 1').to_hash
diff --git a/db/migrate/20181024224956_migrate_account_conversations.rb b/db/migrate/20181024224956_migrate_account_conversations.rb
index 9f6c94fd1..12e0a70fa 100644
--- a/db/migrate/20181024224956_migrate_account_conversations.rb
+++ b/db/migrate/20181024224956_migrate_account_conversations.rb
@@ -62,16 +62,18 @@ class MigrateAccountConversations < ActiveRecord::Migration[5.2]
   end
 
   def up
-    say ''
-    say 'WARNING: This migration may take a *long* time for large instances'
-    say 'It will *not* lock tables for any significant time, but it may run'
-    say 'for a very long time. We will pause for 10 seconds to allow you to'
-    say 'interrupt this migration if you are not ready.'
-    say ''
-
-    10.downto(1) do |i|
-      say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
-      sleep 1
+    if $stdout.isatty
+      say ''
+      say 'WARNING: This migration may take a *long* time for large instances'
+      say 'It will *not* lock tables for any significant time, but it may run'
+      say 'for a very long time. We will pause for 10 seconds to allow you to'
+      say 'interrupt this migration if you are not ready.'
+      say ''
+
+      10.downto(1) do |i|
+        say "Continuing in #{i} second#{i == 1 ? '' : 's'}...", true
+        sleep 1
+      end
     end
 
     migrated  = 0
diff --git a/db/migrate/20191031163205_change_list_account_follow_nullable.rb b/db/migrate/20191031163205_change_list_account_follow_nullable.rb
index ff8911546..65ff93365 100644
--- a/db/migrate/20191031163205_change_list_account_follow_nullable.rb
+++ b/db/migrate/20191031163205_change_list_account_follow_nullable.rb
@@ -1,5 +1,7 @@
 class ChangeListAccountFollowNullable < ActiveRecord::Migration[5.1]
   def change
-    change_column_null :list_accounts, :follow_id, true
+    safety_assured do
+      change_column_null :list_accounts, :follow_id, true
+    end
   end
 end
diff --git a/db/migrate/20191218153258_create_announcements.rb b/db/migrate/20191218153258_create_announcements.rb
new file mode 100644
index 000000000..58e143c92
--- /dev/null
+++ b/db/migrate/20191218153258_create_announcements.rb
@@ -0,0 +1,16 @@
+class CreateAnnouncements < ActiveRecord::Migration[5.2]
+  def change
+    create_table :announcements do |t|
+      t.text :text, null: false, default: ''
+
+      t.boolean :published, null: false, default: false
+      t.boolean :all_day, null: false, default: false
+
+      t.datetime :scheduled_at
+      t.datetime :starts_at
+      t.datetime :ends_at
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20200113125135_create_announcement_mutes.rb b/db/migrate/20200113125135_create_announcement_mutes.rb
new file mode 100644
index 000000000..c588e7fcd
--- /dev/null
+++ b/db/migrate/20200113125135_create_announcement_mutes.rb
@@ -0,0 +1,12 @@
+class CreateAnnouncementMutes < ActiveRecord::Migration[5.2]
+  def change
+    create_table :announcement_mutes do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade, index: false }
+      t.belongs_to :announcement, foreign_key: { on_delete: :cascade }
+
+      t.timestamps
+    end
+
+    add_index :announcement_mutes, [:account_id, :announcement_id], unique: true
+  end
+end
diff --git a/db/migrate/20200114113335_create_announcement_reactions.rb b/db/migrate/20200114113335_create_announcement_reactions.rb
new file mode 100644
index 000000000..226c81a18
--- /dev/null
+++ b/db/migrate/20200114113335_create_announcement_reactions.rb
@@ -0,0 +1,15 @@
+class CreateAnnouncementReactions < ActiveRecord::Migration[5.2]
+  def change
+    create_table :announcement_reactions do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade, index: false }
+      t.belongs_to :announcement, foreign_key: { on_delete: :cascade }
+
+      t.string :name, null: false, default: ''
+      t.belongs_to :custom_emoji, foreign_key: { on_delete: :cascade }
+
+      t.timestamps
+    end
+
+    add_index :announcement_reactions, [:account_id, :announcement_id, :name], unique: true, name: :index_announcement_reactions_on_account_id_and_announcement_id
+  end
+end
diff --git a/db/migrate/20200119112504_add_public_index_to_statuses.rb b/db/migrate/20200119112504_add_public_index_to_statuses.rb
new file mode 100644
index 000000000..db007848e
--- /dev/null
+++ b/db/migrate/20200119112504_add_public_index_to_statuses.rb
@@ -0,0 +1,11 @@
+class AddPublicIndexToStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    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))'
+  end
+
+  def down
+    remove_index :statuses, name: :index_statuses_public_20200119
+  end
+end
diff --git a/db/migrate/20200126203551_add_published_at_to_announcements.rb b/db/migrate/20200126203551_add_published_at_to_announcements.rb
new file mode 100644
index 000000000..d99f95694
--- /dev/null
+++ b/db/migrate/20200126203551_add_published_at_to_announcements.rb
@@ -0,0 +1,5 @@
+class AddPublishedAtToAnnouncements < ActiveRecord::Migration[5.2]
+  def change
+    add_column :announcements, :published_at, :datetime
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b7ab74033..73ac78b80 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2019_12_12_003415) do
+ActiveRecord::Schema.define(version: 2020_01_26_203551) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -196,15 +196,50 @@ ActiveRecord::Schema.define(version: 2019_12_12_003415) do
     t.index ["target_type", "target_id"], name: "index_admin_action_logs_on_target_type_and_target_id"
   end
 
+  create_table "announcement_mutes", force: :cascade do |t|
+    t.bigint "account_id"
+    t.bigint "announcement_id"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id", "announcement_id"], name: "index_announcement_mutes_on_account_id_and_announcement_id", unique: true
+    t.index ["account_id"], name: "index_announcement_mutes_on_account_id"
+    t.index ["announcement_id"], name: "index_announcement_mutes_on_announcement_id"
+  end
+
+  create_table "announcement_reactions", force: :cascade do |t|
+    t.bigint "account_id"
+    t.bigint "announcement_id"
+    t.string "name", default: "", null: false
+    t.bigint "custom_emoji_id"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id", "announcement_id", "name"], name: "index_announcement_reactions_on_account_id_and_announcement_id", unique: true
+    t.index ["account_id"], name: "index_announcement_reactions_on_account_id"
+    t.index ["announcement_id"], name: "index_announcement_reactions_on_announcement_id"
+    t.index ["custom_emoji_id"], name: "index_announcement_reactions_on_custom_emoji_id"
+  end
+
+  create_table "announcements", force: :cascade do |t|
+    t.text "text", default: "", null: false
+    t.boolean "published", default: false, null: false
+    t.boolean "all_day", default: false, null: false
+    t.datetime "scheduled_at"
+    t.datetime "starts_at"
+    t.datetime "ends_at"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.datetime "published_at"
+  end
+
   create_table "backups", force: :cascade do |t|
     t.bigint "user_id"
     t.string "dump_file_name"
     t.string "dump_content_type"
-    t.bigint "dump_file_size"
     t.datetime "dump_updated_at"
     t.boolean "processed", default: false, null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.bigint "dump_file_size"
   end
 
   create_table "blocks", force: :cascade do |t|
@@ -693,6 +728,7 @@ ActiveRecord::Schema.define(version: 2019_12_12_003415) do
     t.datetime "deleted_at"
     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 ["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 ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
@@ -820,6 +856,11 @@ ActiveRecord::Schema.define(version: 2019_12_12_003415) do
   add_foreign_key "account_warnings", "accounts", on_delete: :nullify
   add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
   add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
+  add_foreign_key "announcement_mutes", "accounts", on_delete: :cascade
+  add_foreign_key "announcement_mutes", "announcements", on_delete: :cascade
+  add_foreign_key "announcement_reactions", "accounts", on_delete: :cascade
+  add_foreign_key "announcement_reactions", "announcements", on_delete: :cascade
+  add_foreign_key "announcement_reactions", "custom_emojis", on_delete: :cascade
   add_foreign_key "backups", "users", on_delete: :nullify
   add_foreign_key "blocks", "accounts", column: "target_account_id", name: "fk_9571bfabc1", on_delete: :cascade
   add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade