2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/generators/templates/migration.rb', line 2
def self.up
create_table :survey_surveys do |t|
t.string :name
t.text :description
t.integer :attempts_number, :default => 0
t.boolean :finished, :default => false
t.boolean :active, :default => false
t.timestamps
end
create_table :survey_questions do |t|
t.integer :survey_id
t.string :text
t.timestamps
end
create_table :survey_options do |t|
t.integer :question_id
t.integer :weight, :default => 0
t.string :text
t.boolean :correct
t.timestamps
end
create_table :survey_attempts do |t|
t.belongs_to :participant, :polymorphic => true
t.integer :survey_id
t.boolean :winner
t.integer :score
end
create_table :survey_answers do |t|
t.integer :attempt_id
t.integer :question_id
t.integer :option_id
t.boolean :correct
t.timestamps
end
end
|