Create 'poll_question_answers' table

This commit is contained in:
Angel Perez
2017-10-03 23:04:50 -04:00
parent d9d03079e1
commit 1d1b861ddf
4 changed files with 25 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ class Poll::Question < ActiveRecord::Base
has_many :comments, as: :commentable
has_many :answers
has_many :question_answers, class_name: 'Poll::QuestionAnswer', foreign_key: 'poll_question_id'
has_many :partial_results
belongs_to :proposal

View File

@@ -0,0 +1,5 @@
class Poll::QuestionAnswer < ActiveRecord::Base
belongs_to :question, class_name: 'Poll::Question', foreign_key: 'poll_question_id'
validates :title, presence: true
end

View File

@@ -0,0 +1,9 @@
class CreatePollQuestionAnswers < ActiveRecord::Migration
def change
create_table :poll_question_answers do |t|
t.string :title
t.text :description
t.references :poll_question, index: true, foreign_key: true
end
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: 20171002191347) do
ActiveRecord::Schema.define(version: 20171004025903) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -669,6 +669,14 @@ ActiveRecord::Schema.define(version: 20171002191347) do
add_index "poll_partial_results", ["origin"], name: "index_poll_partial_results_on_origin", using: :btree
add_index "poll_partial_results", ["question_id"], name: "index_poll_partial_results_on_question_id", using: :btree
create_table "poll_question_answers", force: :cascade do |t|
t.string "title"
t.text "description"
t.integer "poll_question_id"
end
add_index "poll_question_answers", ["poll_question_id"], name: "index_poll_question_answers_on_poll_question_id", using: :btree
create_table "poll_questions", force: :cascade do |t|
t.integer "proposal_id"
t.integer "poll_id"
@@ -1143,6 +1151,7 @@ ActiveRecord::Schema.define(version: 20171002191347) do
add_foreign_key "poll_partial_results", "poll_officer_assignments", column: "officer_assignment_id"
add_foreign_key "poll_partial_results", "poll_questions", column: "question_id"
add_foreign_key "poll_partial_results", "users", column: "author_id"
add_foreign_key "poll_question_answers", "poll_questions"
add_foreign_key "poll_questions", "polls"
add_foreign_key "poll_questions", "proposals"
add_foreign_key "poll_questions", "users", column: "author_id"