about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20190225031541_create_polls.rb17
-rw-r--r--db/migrate/20190225031625_create_poll_votes.rb11
-rw-r--r--db/migrate/20190226003449_add_poll_id_to_statuses.rb5
-rw-r--r--db/schema.rb33
4 files changed, 65 insertions, 1 deletions
diff --git a/db/migrate/20190225031541_create_polls.rb b/db/migrate/20190225031541_create_polls.rb
new file mode 100644
index 000000000..ea9ad0425
--- /dev/null
+++ b/db/migrate/20190225031541_create_polls.rb
@@ -0,0 +1,17 @@
+class CreatePolls < ActiveRecord::Migration[5.2]
+  def change
+    create_table :polls do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }
+      t.belongs_to :status, foreign_key: { on_delete: :cascade }
+      t.datetime :expires_at
+      t.string :options, null: false, array: true, default: []
+      t.bigint :cached_tallies, null: false, array: true, default: []
+      t.boolean :multiple, null: false, default: false
+      t.boolean :hide_totals, null: false, default: false
+      t.bigint :votes_count, null: false, default: 0
+      t.datetime :last_fetched_at
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20190225031625_create_poll_votes.rb b/db/migrate/20190225031625_create_poll_votes.rb
new file mode 100644
index 000000000..a0849d3a5
--- /dev/null
+++ b/db/migrate/20190225031625_create_poll_votes.rb
@@ -0,0 +1,11 @@
+class CreatePollVotes < ActiveRecord::Migration[5.2]
+  def change
+    create_table :poll_votes do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }
+      t.belongs_to :poll, foreign_key: { on_delete: :cascade }
+      t.integer :choice, null: false, default: 0
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/migrate/20190226003449_add_poll_id_to_statuses.rb b/db/migrate/20190226003449_add_poll_id_to_statuses.rb
new file mode 100644
index 000000000..692e8f814
--- /dev/null
+++ b/db/migrate/20190226003449_add_poll_id_to_statuses.rb
@@ -0,0 +1,5 @@
+class AddPollIdToStatuses < ActiveRecord::Migration[5.2]
+  def change
+    add_column :statuses, :poll_id, :bigint
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index e9fb358f8..d5d516e06 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: 2019_02_03_180359) do
+ActiveRecord::Schema.define(version: 2019_02_26_003449) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -441,6 +441,32 @@ ActiveRecord::Schema.define(version: 2019_02_03_180359) do
     t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at"
   end
 
+  create_table "poll_votes", force: :cascade do |t|
+    t.bigint "account_id"
+    t.bigint "poll_id"
+    t.integer "choice", default: 0, null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id"], name: "index_poll_votes_on_account_id"
+    t.index ["poll_id"], name: "index_poll_votes_on_poll_id"
+  end
+
+  create_table "polls", force: :cascade do |t|
+    t.bigint "account_id"
+    t.bigint "status_id"
+    t.datetime "expires_at"
+    t.string "options", default: [], null: false, array: true
+    t.bigint "cached_tallies", default: [], null: false, array: true
+    t.boolean "multiple", default: false, null: false
+    t.boolean "hide_totals", default: false, null: false
+    t.bigint "votes_count", default: 0, null: false
+    t.datetime "last_fetched_at"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id"], name: "index_polls_on_account_id"
+    t.index ["status_id"], name: "index_polls_on_status_id"
+  end
+
   create_table "preview_cards", force: :cascade do |t|
     t.string "url", default: "", null: false
     t.string "title", default: "", null: false
@@ -581,6 +607,7 @@ ActiveRecord::Schema.define(version: 2019_02_03_180359) do
     t.bigint "account_id", null: false
     t.bigint "application_id"
     t.bigint "in_reply_to_account_id"
+    t.bigint "poll_id"
     t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
     t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
     t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
@@ -746,6 +773,10 @@ ActiveRecord::Schema.define(version: 2019_02_03_180359) do
   add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id", name: "fk_f5fc4c1ee3", on_delete: :cascade
   add_foreign_key "oauth_access_tokens", "users", column: "resource_owner_id", name: "fk_e84df68546", on_delete: :cascade
   add_foreign_key "oauth_applications", "users", column: "owner_id", name: "fk_b0988c7c0a", on_delete: :cascade
+  add_foreign_key "poll_votes", "accounts", on_delete: :cascade
+  add_foreign_key "poll_votes", "polls", on_delete: :cascade
+  add_foreign_key "polls", "accounts", on_delete: :cascade
+  add_foreign_key "polls", "statuses", on_delete: :cascade
   add_foreign_key "report_notes", "accounts", on_delete: :cascade
   add_foreign_key "report_notes", "reports", on_delete: :cascade
   add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify