Skip to content

Commit

Permalink
changes poll_voters to optionally reference an answer
Browse files Browse the repository at this point in the history
adds indexes for poll_voters
  • Loading branch information
xuanxu committed Jan 25, 2017
1 parent 6bc4f5b commit 5806d86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions db/migrate/20170125114952_add_answer_id_to_poll_voters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddAnswerIdToPollVoters < ActiveRecord::Migration
def change
add_column :poll_voters, :answer_id, :integer, default: nil

add_index :poll_voters, :document_number
add_index :poll_voters, :poll_id
add_index :poll_voters, [:poll_id, :document_number, :document_type], name: 'doc_by_poll'
end
end
7 changes: 6 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20170125112017) do
ActiveRecord::Schema.define(version: 20170125114952) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -468,8 +468,13 @@
t.integer "age"
t.string "gender"
t.integer "geozone_id"
t.integer "answer_id"
end

add_index "poll_voters", ["document_number"], name: "index_poll_voters_on_document_number", using: :btree
add_index "poll_voters", ["poll_id", "document_number", "document_type"], name: "doc_by_poll", using: :btree
add_index "poll_voters", ["poll_id"], name: "index_poll_voters_on_poll_id", using: :btree

create_table "polls", force: :cascade do |t|
t.string "name"
t.datetime "starts_at"
Expand Down

0 comments on commit 5806d86

Please sign in to comment.