diff --git a/db/migrate/20200120124150_create_structured_data_schemas.rb b/db/migrate/20200120124150_create_structured_data_schemas.rb index 2d41697..67b3801 100644 --- a/db/migrate/20200120124150_create_structured_data_schemas.rb +++ b/db/migrate/20200120124150_create_structured_data_schemas.rb @@ -6,6 +6,7 @@ t.integer :version t.json :schema t.integer :org_id + t.belongs_to :org, foreign_key: true, index: true t.string :object t.timestamps null: false diff --git a/db/migrate/20200120124811_create_structured_answers.rb b/db/migrate/20200120124811_create_structured_answers.rb index 326df97..2e9cbe0 100644 --- a/db/migrate/20200120124811_create_structured_answers.rb +++ b/db/migrate/20200120124811_create_structured_answers.rb @@ -2,8 +2,8 @@ def change create_table :structured_answers do |t| t.json :data - t.integer :answer_id - t.integer :structured_data_schema_id + t.belongs_to :answer, foreign_key: true, index: true + t.belongs_to :structured_data_schema, foreign_key: true, index: true t.timestamps null: false end diff --git a/db/migrate/20200120134348_add_schema_id_to_questions.rb b/db/migrate/20200120134348_add_schema_id_to_questions.rb index 971919b..e015c9c 100644 --- a/db/migrate/20200120134348_add_schema_id_to_questions.rb +++ b/db/migrate/20200120134348_add_schema_id_to_questions.rb @@ -1,5 +1,5 @@ class AddSchemaIdToQuestions < ActiveRecord::Migration def change - add_column :questions, :schema_id, :integer + add_reference :questions, :schema_id, foreign_key: true, index: true end end