changes poll_voters to optionally reference an answer

adds indexes for poll_voters
This commit is contained in:
Juanjo Bazán
2017-01-25 12:57:00 +01:00
parent 6bc4f5b307
commit 5806d86e33
2 changed files with 15 additions and 1 deletions

View File

@@ -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

View File

@@ -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"
@@ -468,8 +468,13 @@ ActiveRecord::Schema.define(version: 20170125112017) do
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"