about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorStarfall <admin@plural.cafe>2020-07-01 12:06:19 -0500
committerStarfall <admin@plural.cafe>2020-07-01 12:06:19 -0500
commit4d93b5c442ff5c9f4d640b4c7d543f0c04c120df (patch)
tree4df391c12dc761ac99ca6421d53d8d31870b68ec /db
parent5668836f56cddf3257f38a2483c1d42cacbad3a8 (diff)
parent39a0622de70dc24275808cee9526658bd68a55ed (diff)
Merge branch 'glitch' into main
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb12
-rw-r--r--db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb15
-rw-r--r--db/migrate/20200627125810_add_thumbnail_columns_to_media_attachments.rb11
-rw-r--r--db/migrate/20200628133322_create_account_notes.rb13
-rw-r--r--db/schema.rb28
5 files changed, 70 insertions, 9 deletions
diff --git a/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb
new file mode 100644
index 000000000..e2eaf46f1
--- /dev/null
+++ b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb
@@ -0,0 +1,12 @@
+class RemoveDuplicatedIndexesPghero < ActiveRecord::Migration[5.2]
+  def change
+    remove_index :account_conversations, name: "index_account_conversations_on_account_id", column: :account_id
+    remove_index :account_identity_proofs, name: "index_account_identity_proofs_on_account_id", column: :account_id
+    remove_index :account_pins, name: "index_account_pins_on_account_id", column: :account_id
+    remove_index :announcement_mutes, name: "index_announcement_mutes_on_account_id", column: :account_id
+    remove_index :announcement_reactions, name: "index_announcement_reactions_on_account_id", column: :account_id
+    remove_index :bookmarks, name: "index_bookmarks_on_account_id", column: :account_id
+    remove_index :markers, name: "index_markers_on_user_id", column: :user_id
+  end
+end
+
diff --git a/db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb b/db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb
new file mode 100644
index 000000000..c5688681f
--- /dev/null
+++ b/db/migrate/20200620164023_add_fixed_lowercase_index_to_accounts.rb
@@ -0,0 +1,15 @@
+class AddFixedLowercaseIndexToAccounts < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    rename_index :accounts, 'index_accounts_on_username_and_domain_lower', 'old_index_accounts_on_username_and_domain_lower' unless index_name_exists?(:accounts, 'old_index_accounts_on_username_and_domain_lower')
+    add_index :accounts, "lower (username), COALESCE(lower(domain), '')", name: 'index_accounts_on_username_and_domain_lower', unique: true, algorithm: :concurrently
+    remove_index :accounts, name: 'old_index_accounts_on_username_and_domain_lower'
+  end
+
+  def down
+    add_index :accounts, 'lower (username), lower(domain)', name: 'old_index_accounts_on_username_and_domain_lower', unique: true, algorithm: :concurrently
+    remove_index :accounts, name: 'index_accounts_on_username_and_domain_lower'
+    rename_index :accounts, 'old_index_accounts_on_username_and_domain_lower', 'index_accounts_on_username_and_domain_lower'
+  end
+end
diff --git a/db/migrate/20200627125810_add_thumbnail_columns_to_media_attachments.rb b/db/migrate/20200627125810_add_thumbnail_columns_to_media_attachments.rb
new file mode 100644
index 000000000..f9c87a53c
--- /dev/null
+++ b/db/migrate/20200627125810_add_thumbnail_columns_to_media_attachments.rb
@@ -0,0 +1,11 @@
+class AddThumbnailColumnsToMediaAttachments < ActiveRecord::Migration[5.2]
+  def up
+    add_attachment :media_attachments, :thumbnail
+    add_column :media_attachments, :thumbnail_remote_url, :string
+  end
+
+  def down
+    remove_attachment :media_attachments, :thumbnail
+    remove_column :media_attachments, :thumbnail_remote_url
+  end
+end
diff --git a/db/migrate/20200628133322_create_account_notes.rb b/db/migrate/20200628133322_create_account_notes.rb
new file mode 100644
index 000000000..664727e60
--- /dev/null
+++ b/db/migrate/20200628133322_create_account_notes.rb
@@ -0,0 +1,13 @@
+class CreateAccountNotes < ActiveRecord::Migration[5.2]
+  def change
+    create_table :account_notes do |t|
+      t.references :account, foreign_key: { on_delete: :cascade }, index: false
+      t.references :target_account, foreign_key: { to_table: :accounts, on_delete: :cascade }
+      t.text :comment, null: false
+      t.index [:account_id, :target_account_id], unique: true
+
+      t.timestamps
+    end
+  end
+end
+
diff --git a/db/schema.rb b/db/schema.rb
index c1b6ffa81..ee6954813 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: 2020_06_08_113046) do
+ActiveRecord::Schema.define(version: 2020_06_28_133322) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -33,7 +33,6 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.integer "lock_version", default: 0, null: false
     t.boolean "unread", default: false, null: false
     t.index ["account_id", "conversation_id", "participant_account_ids"], name: "index_unique_conversations", unique: true
-    t.index ["account_id"], name: "index_account_conversations_on_account_id"
     t.index ["conversation_id"], name: "index_account_conversations_on_conversation_id"
   end
 
@@ -55,7 +54,6 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.index ["account_id", "provider", "provider_username"], name: "index_account_proofs_on_account_and_provider_and_username", unique: true
-    t.index ["account_id"], name: "index_account_identity_proofs_on_account_id"
   end
 
   create_table "account_migrations", force: :cascade do |t|
@@ -85,7 +83,6 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.index ["account_id", "target_account_id"], name: "index_account_pins_on_account_id_and_target_account_id", unique: true
-    t.index ["account_id"], name: "index_account_pins_on_account_id"
     t.index ["target_account_id"], name: "index_account_pins_on_target_account_id"
   end
 
@@ -176,7 +173,7 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.integer "header_storage_schema_version"
     t.string "devices_url"
     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), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
+    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"
     t.index ["uri"], name: "index_accounts_on_uri"
     t.index ["url"], name: "index_accounts_on_url"
@@ -207,7 +204,6 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     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
 
@@ -219,7 +215,6 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     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
@@ -264,7 +259,6 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.index ["account_id", "status_id"], name: "index_bookmarks_on_account_id_and_status_id", unique: true
-    t.index ["account_id"], name: "index_bookmarks_on_account_id"
     t.index ["status_id"], name: "index_bookmarks_on_status_id"
   end
 
@@ -476,7 +470,6 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
     t.index ["user_id", "timeline"], name: "index_markers_on_user_id_and_timeline", unique: true
-    t.index ["user_id"], name: "index_markers_on_user_id"
   end
 
   create_table "media_attachments", force: :cascade do |t|
@@ -497,6 +490,11 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.string "blurhash"
     t.integer "processing"
     t.integer "file_storage_schema_version"
+    t.string "thumbnail_file_name"
+    t.string "thumbnail_content_type"
+    t.integer "thumbnail_file_size"
+    t.datetime "thumbnail_updated_at"
+    t.string "thumbnail_remote_url"
     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
@@ -838,6 +836,16 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
     t.index ["user_id"], name: "index_user_invite_requests_on_user_id"
   end
 
+  create_table "account_notes", force: :cascade do |t|
+    t.bigint "account_id"
+    t.bigint "target_account_id"
+    t.text "comment", null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id", "target_account_id"], name: "index_account_notes_on_account_id_and_target_account_id", unique: true
+    t.index ["target_account_id"], name: "index_account_notes_on_target_account_id"
+  end
+
   create_table "users", force: :cascade do |t|
     t.string "email", default: "", null: false
     t.datetime "created_at", null: false
@@ -994,6 +1002,8 @@ ActiveRecord::Schema.define(version: 2020_06_08_113046) do
   add_foreign_key "statuses_tags", "tags", name: "fk_3081861e21", on_delete: :cascade
   add_foreign_key "tombstones", "accounts", on_delete: :cascade
   add_foreign_key "user_invite_requests", "users", on_delete: :cascade
+  add_foreign_key "account_notes", "accounts", column: "target_account_id", on_delete: :cascade
+  add_foreign_key "account_notes", "accounts", on_delete: :cascade
   add_foreign_key "users", "accounts", name: "fk_50500f500d", on_delete: :cascade
   add_foreign_key "users", "invites", on_delete: :nullify
   add_foreign_key "users", "oauth_applications", column: "created_by_application_id", on_delete: :nullify