Class: CreateResponses

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/surveyor/templates/db/migrate/create_responses.rb

Class Method Summary collapse

Class Method Details

.downObject



31
32
33
# File 'lib/generators/surveyor/templates/db/migrate/create_responses.rb', line 31

def self.down
  drop_table :responses
end

.upObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/surveyor/templates/db/migrate/create_responses.rb', line 3

def self.up
  create_table :responses do |t|
    # Context
    t.integer :response_set_id
    t.integer :question_id

    # Content
    t.integer :answer_id
    t.datetime :datetime_value # handles date, time, and datetime (segregate by answer.response_class)

    #t.datetime :time_value
    t.integer :integer_value
    t.float :float_value
    t.string :unit
    t.text :text_value
    t.string :string_value
    t.string :response_other #used to hold the string entered with "Other" type answers in multiple choice questions

    # arbitrary identifier used to group responses
    # the pertinent example here is Q: What's your car's make/model/year
    # group 1: Ford/Focus/2007
    # group 2: Toyota/Prius/2006
    t.string :response_group

    t.timestamps
  end
end