about summary refs log tree commit diff
path: root/db/migrate/20180929222014_create_account_conversations.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-10-08 13:51:33 +0200
committerThibaut Girka <thib@sitedethib.com>2018-10-08 13:51:33 +0200
commitd17844e6d1ad700df0f704972e2ce16e8693d33b (patch)
treeada49442558fb14c6cf97e79fb6e2dcaa237c7a6 /db/migrate/20180929222014_create_account_conversations.rb
parent96c3d26870d4c8db1978c86b259e85d060d6f271 (diff)
parent4c4ff05a461eddafbf38c603b1bf2029be36a0b9 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'db/migrate/20180929222014_create_account_conversations.rb')
-rw-r--r--db/migrate/20180929222014_create_account_conversations.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/db/migrate/20180929222014_create_account_conversations.rb b/db/migrate/20180929222014_create_account_conversations.rb
new file mode 100644
index 000000000..53fa137e1
--- /dev/null
+++ b/db/migrate/20180929222014_create_account_conversations.rb
@@ -0,0 +1,14 @@
+class CreateAccountConversations < ActiveRecord::Migration[5.2]
+  def change
+    create_table :account_conversations do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }
+      t.belongs_to :conversation, foreign_key: { on_delete: :cascade }
+      t.bigint :participant_account_ids, array: true, null: false, default: []
+      t.bigint :status_ids, array: true, null: false, default: []
+      t.bigint :last_status_id, null: true, default: nil
+      t.integer :lock_version, null: false, default: 0
+    end
+
+    add_index :account_conversations, [:account_id, :conversation_id, :participant_account_ids], unique: true, name: 'index_unique_conversations'
+  end
+end