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/20190805203816_create_linked_users.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/migrate/20190805203816_create_linked_users.rb b/db/migrate/20190805203816_create_linked_users.rb
new file mode 100644
index 000000000..36744fed6
--- /dev/null
+++ b/db/migrate/20190805203816_create_linked_users.rb
@@ -0,0 +1,12 @@
+class CreateLinkedUsers < ActiveRecord::Migration[5.2]
+  def change
+    create_table :linked_users do |t|
+      t.references :user, foreign_key: { on_delete: :cascade }
+      t.references :target_user, foreign_key: { to_table: 'users', on_delete: :cascade }
+
+      t.timestamps
+    end
+
+    add_index :linked_users , [:user_id, :target_user_id], :unique => true
+  end
+end