about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-15 13:34:05 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-15 14:12:24 -0500
commitcf3ec71aa564c7fe47ec79f8dd5f14e3bce0b85c (patch)
tree49a3356c4177157b377aeca223a7d1c1e2e3dc17 /db
parent0a5eba734e6aa6a6e7e8f64b022af8ea129c9f5d (diff)
local visibility scope, chat scope+tags, unlisted tags
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20190522043937_add_chat_and_local_indexes_to_statuses.rb6
-rw-r--r--db/migrate/20190522060455_add_unlisted_to_tags.rb9
-rw-r--r--db/migrate/20190522060919_make_private_tags_unlisted.rb5
-rw-r--r--db/migrate/20190523010615_add_chat_to_tags.rb9
-rw-r--r--db/migrate/20190526052454_create_chat_accounts.rb11
-rw-r--r--db/schema.rb17
6 files changed, 57 insertions, 0 deletions
diff --git a/db/migrate/20190522043937_add_chat_and_local_indexes_to_statuses.rb b/db/migrate/20190522043937_add_chat_and_local_indexes_to_statuses.rb
new file mode 100644
index 000000000..ad4bb11b1
--- /dev/null
+++ b/db/migrate/20190522043937_add_chat_and_local_indexes_to_statuses.rb
@@ -0,0 +1,6 @@
+class AddChatAndLocalIndexesToStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+  def change
+    add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2, 4, 5)', algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20190522060455_add_unlisted_to_tags.rb b/db/migrate/20190522060455_add_unlisted_to_tags.rb
new file mode 100644
index 000000000..3c47af673
--- /dev/null
+++ b/db/migrate/20190522060455_add_unlisted_to_tags.rb
@@ -0,0 +1,9 @@
+class AddUnlistedToTags < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+  def change
+    safety_assured {
+      add_column :tags, :unlisted, :boolean, default: false, null: false
+      add_index :tags, :unlisted, where: :unlisted, algorithm: :concurrently
+    }
+  end
+end
diff --git a/db/migrate/20190522060919_make_private_tags_unlisted.rb b/db/migrate/20190522060919_make_private_tags_unlisted.rb
new file mode 100644
index 000000000..92f610d57
--- /dev/null
+++ b/db/migrate/20190522060919_make_private_tags_unlisted.rb
@@ -0,0 +1,5 @@
+class MakePrivateTagsUnlisted < ActiveRecord::Migration[5.2]
+  def up
+    Tag.where(private: true).in_batches.update_all(unlisted: true)
+  end
+end
diff --git a/db/migrate/20190523010615_add_chat_to_tags.rb b/db/migrate/20190523010615_add_chat_to_tags.rb
new file mode 100644
index 000000000..1fc3cadfa
--- /dev/null
+++ b/db/migrate/20190523010615_add_chat_to_tags.rb
@@ -0,0 +1,9 @@
+class AddChatToTags < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+  def change
+    safety_assured {
+      add_column :tags, :chat, :boolean, default: false, null: false
+      add_index :tags, :chat, where: :chat, algorithm: :concurrently
+    }
+  end
+end
diff --git a/db/migrate/20190526052454_create_chat_accounts.rb b/db/migrate/20190526052454_create_chat_accounts.rb
new file mode 100644
index 000000000..b950e36c1
--- /dev/null
+++ b/db/migrate/20190526052454_create_chat_accounts.rb
@@ -0,0 +1,11 @@
+class CreateChatAccounts < ActiveRecord::Migration[5.2]
+  def change
+    create_table :chat_accounts do |t|
+      t.references :account, foreign_key: { on_delete: :cascade }, null: false
+      t.references :tag, foreign_key: { on_delete: :cascade }, null: false
+      t.index [:account_id, :tag_id], unique: true
+      t.index [:tag_id, :account_id]
+      t.timestamps
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 600837334..0cfefbf7f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -208,6 +208,17 @@ ActiveRecord::Schema.define(version: 2019_05_21_003909) do
     t.index ["status_id"], name: "index_bookmarks_on_status_id"
   end
 
+  create_table "chat_accounts", force: :cascade do |t|
+    t.bigint "account_id", null: false
+    t.bigint "tag_id", null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id", "tag_id"], name: "index_chat_accounts_on_account_id_and_tag_id", unique: true
+    t.index ["account_id"], name: "index_chat_accounts_on_account_id"
+    t.index ["tag_id", "account_id"], name: "index_chat_accounts_on_tag_id_and_account_id"
+    t.index ["tag_id"], name: "index_chat_accounts_on_tag_id"
+  end
+
   create_table "conversation_mutes", force: :cascade do |t|
     t.bigint "conversation_id", null: false
     t.bigint "account_id", null: false
@@ -687,8 +698,12 @@ ActiveRecord::Schema.define(version: 2019_05_21_003909) do
     t.datetime "updated_at", null: false
     t.boolean "local", default: false, null: false
     t.boolean "private", default: false, null: false
+    t.boolean "unlisted", default: false, null: false
+    t.boolean "chat", default: false, null: false
     t.index "lower((name)::text) text_pattern_ops", name: "hashtag_search_index"
+    t.index ["chat"], name: "index_tags_on_chat", where: "chat"
     t.index ["name"], name: "index_tags_on_name", unique: true
+    t.index ["unlisted"], name: "index_tags_on_unlisted", where: "unlisted"
   end
 
   create_table "tombstones", force: :cascade do |t|
@@ -791,6 +806,8 @@ ActiveRecord::Schema.define(version: 2019_05_21_003909) 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 "chat_accounts", "accounts", on_delete: :cascade
+  add_foreign_key "chat_accounts", "tags", 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_filters", "accounts", on_delete: :cascade