about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-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
5 files changed, 40 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