about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20171114231651_create_lists.rb10
-rw-r--r--db/migrate/20171116161857_create_list_accounts.rb12
-rw-r--r--db/schema.rb25
3 files changed, 46 insertions, 1 deletions
diff --git a/db/migrate/20171114231651_create_lists.rb b/db/migrate/20171114231651_create_lists.rb
new file mode 100644
index 000000000..21285e901
--- /dev/null
+++ b/db/migrate/20171114231651_create_lists.rb
@@ -0,0 +1,10 @@
+class CreateLists < ActiveRecord::Migration[5.1]
+  def change
+    create_table :lists do |t|
+      t.references :account, foreign_key: { on_delete: :cascade }
+      t.string :title, null: false, default: ''
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20171116161857_create_list_accounts.rb b/db/migrate/20171116161857_create_list_accounts.rb
new file mode 100644
index 000000000..b76c90651
--- /dev/null
+++ b/db/migrate/20171116161857_create_list_accounts.rb
@@ -0,0 +1,12 @@
+class CreateListAccounts < ActiveRecord::Migration[5.1]
+  def change
+    create_table :list_accounts do |t|
+      t.belongs_to :list, foreign_key: { on_delete: :cascade }, null: false
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }, null: false
+      t.belongs_to :follow, foreign_key: { on_delete: :cascade }, null: false
+    end
+
+    add_index :list_accounts, [:account_id, :list_id], unique: true
+    add_index :list_accounts, [:list_id, :account_id]
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2d763e2f4..345b05850 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: 20171114080328) do
+ActiveRecord::Schema.define(version: 20171116161857) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -170,6 +170,25 @@ ActiveRecord::Schema.define(version: 20171114080328) do
     t.bigint "account_id", null: false
   end
 
+  create_table "list_accounts", force: :cascade do |t|
+    t.bigint "list_id", null: false
+    t.bigint "account_id", null: false
+    t.bigint "follow_id", null: false
+    t.index ["account_id", "list_id"], name: "index_list_accounts_on_account_id_and_list_id", unique: true
+    t.index ["account_id"], name: "index_list_accounts_on_account_id"
+    t.index ["follow_id"], name: "index_list_accounts_on_follow_id"
+    t.index ["list_id", "account_id"], name: "index_list_accounts_on_list_id_and_account_id"
+    t.index ["list_id"], name: "index_list_accounts_on_list_id"
+  end
+
+  create_table "lists", force: :cascade do |t|
+    t.bigint "account_id"
+    t.string "title", default: "", null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id"], name: "index_lists_on_account_id"
+  end
+
   create_table "media_attachments", force: :cascade do |t|
     t.bigint "status_id"
     t.string "file_file_name"
@@ -478,6 +497,10 @@ ActiveRecord::Schema.define(version: 20171114080328) do
   add_foreign_key "follows", "accounts", column: "target_account_id", name: "fk_745ca29eac", on_delete: :cascade
   add_foreign_key "follows", "accounts", name: "fk_32ed1b5560", on_delete: :cascade
   add_foreign_key "imports", "accounts", name: "fk_6db1b6e408", on_delete: :cascade
+  add_foreign_key "list_accounts", "accounts", on_delete: :cascade
+  add_foreign_key "list_accounts", "follows", on_delete: :cascade
+  add_foreign_key "list_accounts", "lists", on_delete: :cascade
+  add_foreign_key "lists", "accounts", on_delete: :cascade
   add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify
   add_foreign_key "media_attachments", "statuses", on_delete: :nullify
   add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade