diff --git a/app/models/annotation.rb b/app/models/annotation.rb index cae2564..6a9ee9c 100644 --- a/app/models/annotation.rb +++ b/app/models/annotation.rb @@ -3,12 +3,12 @@ # Table name: annotations # # id :integer not null, primary key +# question_id :integer +# org_id :integer # text :text -# type :integer default(0), not null +# type :integer default("0"), not null # created_at :datetime # updated_at :datetime -# org_id :integer -# question_id :integer # versionable_id :string(36) # # Indexes @@ -17,11 +17,6 @@ # annotations_question_id_idx (question_id) # index_annotations_on_versionable_id (versionable_id) # -# Foreign Keys -# -# fk_rails_... (org_id => orgs.id) -# fk_rails_... (question_id => questions.id) -# class Annotation < ActiveRecord::Base include ValidationMessages diff --git a/app/models/answer.rb b/app/models/answer.rb index fd6e10f..42c81fc 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -4,15 +4,15 @@ # Table name: answers # # id :integer not null, primary key -# is_common :boolean default(FALSE) -# lock_version :integer default(0) # text :text +# plan_id :integer +# user_id :integer +# question_id :integer # created_at :datetime # updated_at :datetime -# plan_id :integer -# question_id :integer +# lock_version :integer default("0") +# is_common :boolean default("false") # research_output_id :integer -# user_id :integer # # Indexes # @@ -21,13 +21,6 @@ # answers_user_id_idx (user_id) # index_answers_on_research_output_id (research_output_id) # -# Foreign Keys -# -# fk_rails_... (plan_id => plans.id) -# fk_rails_... (question_id => questions.id) -# fk_rails_... (research_output_id => research_outputs.id) -# fk_rails_... (user_id => users.id) -# class Answer < ActiveRecord::Base @@ -52,6 +45,8 @@ has_many :notes + has_one :structured_answer + # =============== # = Validations = diff --git a/app/models/guidance.rb b/app/models/guidance.rb index a0b9d19..6ac4977 100644 --- a/app/models/guidance.rb +++ b/app/models/guidance.rb @@ -9,20 +9,16 @@ # Table name: guidances # # id :integer not null, primary key -# published :boolean # text :text +# guidance_group_id :integer # created_at :datetime not null # updated_at :datetime not null -# guidance_group_id :integer +# published :boolean # # Indexes # # guidances_guidance_group_id_idx (guidance_group_id) # -# Foreign Keys -# -# fk_rails_... (guidance_group_id => guidance_groups.id) -# # [+Project:+] DMPRoadmap # [+Description:+] diff --git a/app/models/guidance_group.rb b/app/models/guidance_group.rb index 45074d0..7d049be 100644 --- a/app/models/guidance_group.rb +++ b/app/models/guidance_group.rb @@ -9,20 +9,16 @@ # # id :integer not null, primary key # name :string -# optional_subset :boolean default(FALSE), not null -# published :boolean default(FALSE), not null +# org_id :integer # created_at :datetime not null # updated_at :datetime not null -# org_id :integer +# optional_subset :boolean default("false"), not null +# published :boolean default("false"), not null # # Indexes # # guidance_groups_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (org_id => orgs.id) -# class GuidanceGroup < ActiveRecord::Base diff --git a/app/models/note.rb b/app/models/note.rb index 8ab9991..41a2074 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -3,24 +3,19 @@ # Table name: notes # # id :integer not null, primary key -# archived :boolean default(FALSE), not null -# archived_by :integer +# user_id :integer # text :text +# archived :boolean default("false"), not null +# answer_id :integer +# archived_by :integer # created_at :datetime # updated_at :datetime -# answer_id :integer -# user_id :integer # # Indexes # # notes_answer_id_idx (answer_id) # notes_user_id_idx (user_id) # -# Foreign Keys -# -# fk_rails_... (answer_id => answers.id) -# fk_rails_... (user_id => users.id) -# class Note < ActiveRecord::Base include ValidationMessages diff --git a/app/models/org.rb b/app/models/org.rb index c5acca1..590fbb5 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -1,40 +1,34 @@ # frozen_string_literal: true - # == Schema Information # # Table name: orgs # # id :integer not null, primary key -# abbreviation :string -# banner_text :text -# contact_email :string -# contact_name :string -# feedback_email_msg :text -# feedback_email_subject :string -# feedback_enabled :boolean default(FALSE) -# is_other :boolean default(FALSE), not null -# links :text -# logo_name :string -# logo_uid :string # name :string -# org_type :integer default(0), not null -# sort_name :string +# abbreviation :string # target_url :string # created_at :datetime not null # updated_at :datetime not null -# language_id :integer +# is_other :boolean default("false"), not null +# sort_name :string +# banner_text :text # region_id :integer +# language_id :integer +# logo_uid :string +# logo_name :string +# contact_email :string +# org_type :integer default("0"), not null +# links :text +# contact_name :string +# feedback_enabled :boolean default("false") +# feedback_email_subject :string +# feedback_email_msg :text # # Indexes # # orgs_language_id_idx (language_id) # orgs_region_id_idx (region_id) # -# Foreign Keys -# -# fk_rails_... (language_id => languages.id) -# fk_rails_... (region_id => regions.id) -# class Org < ActiveRecord::Base @@ -85,6 +79,8 @@ has_many :departments + has_many :structured_data_schemas + # =============== # = Validations = # =============== diff --git a/app/models/org_identifier.rb b/app/models/org_identifier.rb index 4d14cc7..3c129d3 100644 --- a/app/models/org_identifier.rb +++ b/app/models/org_identifier.rb @@ -3,23 +3,18 @@ # Table name: org_identifiers # # id :integer not null, primary key -# attrs :string # identifier :string +# attrs :string # created_at :datetime # updated_at :datetime -# identifier_scheme_id :integer # org_id :integer +# identifier_scheme_id :integer # # Indexes # # org_identifiers_identifier_scheme_id_idx (identifier_scheme_id) # org_identifiers_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (identifier_scheme_id => identifier_schemes.id) -# fk_rails_... (org_id => orgs.id) -# class OrgIdentifier < ActiveRecord::Base include ValidationMessages diff --git a/app/models/phase.rb b/app/models/phase.rb index 1798379..006aa70 100644 --- a/app/models/phase.rb +++ b/app/models/phase.rb @@ -3,13 +3,13 @@ # Table name: phases # # id :integer not null, primary key -# description :text -# modifiable :boolean -# number :integer # title :string +# description :text +# number :integer +# template_id :integer # created_at :datetime # updated_at :datetime -# template_id :integer +# modifiable :boolean # versionable_id :string(36) # # Indexes @@ -17,10 +17,6 @@ # index_phases_on_versionable_id (versionable_id) # phases_template_id_idx (template_id) # -# Foreign Keys -# -# fk_rails_... (template_id => templates.id) -# # [+Project:+] DMPRoadmap # [+Description:+] This model describes informmation about the phase of a plan, it's title, order of display and which template it belongs to. diff --git a/app/models/plan.rb b/app/models/plan.rb index 7365ffc..2684ddc 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -8,33 +8,29 @@ # Table name: plans # # id :integer not null, primary key -# complete :boolean default(FALSE) -# data_contact :string -# data_contact_email :string -# data_contact_phone :string -# description :text -# feedback_requested :boolean default(FALSE) -# funder_name :string -# grant_number :string -# identifier :string -# principal_investigator :string -# principal_investigator_email :string -# principal_investigator_identifier :string -# principal_investigator_phone :string # title :string -# visibility :integer default(3), not null +# template_id :integer # created_at :datetime # updated_at :datetime -# template_id :integer +# grant_number :string +# identifier :string +# description :text +# principal_investigator :string +# principal_investigator_identifier :string +# data_contact :string +# funder_name :string +# visibility :integer default("3"), not null +# data_contact_email :string +# data_contact_phone :string +# principal_investigator_email :string +# principal_investigator_phone :string +# feedback_requested :boolean default("false") +# complete :boolean default("false") # # Indexes # # plans_template_id_idx (template_id) # -# Foreign Keys -# -# fk_rails_... (template_id => templates.id) -# class Plan < ActiveRecord::Base diff --git a/app/models/question.rb b/app/models/question.rb index 14a65c4..fe377ff 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -4,16 +4,18 @@ # Table name: questions # # id :integer not null, primary key -# default_value :text -# modifiable :boolean -# number :integer -# option_comment_display :boolean default(TRUE) # text :text +# default_value :text +# number :integer +# section_id :integer # created_at :datetime # updated_at :datetime # question_format_id :integer -# section_id :integer +# option_comment_display :boolean default("true") +# modifiable :boolean # versionable_id :string(36) +# structured :boolean default("false"), not null +# schema_id :integer # # Indexes # @@ -21,11 +23,6 @@ # questions_question_format_id_idx (question_format_id) # questions_section_id_idx (section_id) # -# Foreign Keys -# -# fk_rails_... (question_format_id => question_formats.id) -# fk_rails_... (section_id => sections.id) -# class Question < ActiveRecord::Base @@ -65,6 +62,8 @@ has_one :template, through: :section + belongs_to :structured_data_schema + # =============== # = Validations = # =============== diff --git a/app/models/question_format.rb b/app/models/question_format.rb index c3f96ef..8d0e228 100644 --- a/app/models/question_format.rb +++ b/app/models/question_format.rb @@ -3,12 +3,12 @@ # Table name: question_formats # # id :integer not null, primary key -# description :text -# formattype :integer default(0) -# option_based :boolean default(FALSE) # title :string +# description :text # created_at :datetime not null # updated_at :datetime not null +# option_based :boolean default("false") +# formattype :integer default("0") # class QuestionFormat < ActiveRecord::Base diff --git a/app/models/question_option.rb b/app/models/question_option.rb index 745720d..7be0fec 100644 --- a/app/models/question_option.rb +++ b/app/models/question_option.rb @@ -3,21 +3,17 @@ # Table name: question_options # # id :integer not null, primary key -# is_default :boolean -# number :integer +# question_id :integer # text :string +# number :integer +# is_default :boolean # created_at :datetime # updated_at :datetime -# question_id :integer # # Indexes # # question_options_question_id_idx (question_id) # -# Foreign Keys -# -# fk_rails_... (question_id => questions.id) -# class QuestionOption < ActiveRecord::Base include ValidationMessages diff --git a/app/models/research_output.rb b/app/models/research_output.rb index 677d5bc..6a0ff05 100644 --- a/app/models/research_output.rb +++ b/app/models/research_output.rb @@ -4,14 +4,14 @@ # # id :integer not null, primary key # abbreviation :string -# fullname :string -# is_default :boolean default(FALSE) # order :integer -# other_type_label :string -# pid :string +# fullname :string +# is_default :boolean default("false") +# plan_id :integer # created_at :datetime not null # updated_at :datetime not null -# plan_id :integer +# pid :string +# other_type_label :string # research_output_type_id :integer # # Indexes @@ -19,11 +19,6 @@ # index_research_outputs_on_plan_id (plan_id) # index_research_outputs_on_research_output_type_id (research_output_type_id) # -# Foreign Keys -# -# fk_rails_... (plan_id => plans.id) -# fk_rails_... (research_output_type_id => research_output_types.id) -# class ResearchOutput < ActiveRecord::Base include ValidationMessages diff --git a/app/models/research_output_type.rb b/app/models/research_output_type.rb index 269d2a8..bb4f2c9 100644 --- a/app/models/research_output_type.rb +++ b/app/models/research_output_type.rb @@ -3,9 +3,9 @@ # Table name: research_output_types # # id :integer not null, primary key -# is_other :boolean default(FALSE), not null # label :string not null # slug :string not null +# is_other :boolean default("false"), not null # created_at :datetime not null # updated_at :datetime not null # diff --git a/app/models/role.rb b/app/models/role.rb index c805f04..d913d2e 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -3,23 +3,18 @@ # Table name: roles # # id :integer not null, primary key -# access :integer default(0), not null -# active :boolean default(FALSE) +# user_id :integer +# plan_id :integer # created_at :datetime # updated_at :datetime -# plan_id :integer -# user_id :integer +# access :integer default("0"), not null +# active :boolean default("false") # # Indexes # # roles_plan_id_idx (plan_id) # roles_user_id_idx (user_id) # -# Foreign Keys -# -# fk_rails_... (plan_id => plans.id) -# fk_rails_... (user_id => users.id) -# class Role < ActiveRecord::Base diff --git a/app/models/section.rb b/app/models/section.rb index b87b122..d2bd08f 100644 --- a/app/models/section.rb +++ b/app/models/section.rb @@ -4,13 +4,13 @@ # Table name: sections # # id :integer not null, primary key -# description :text -# modifiable :boolean -# number :integer # title :string +# description :text +# number :integer # created_at :datetime # updated_at :datetime # phase_id :integer +# modifiable :boolean # versionable_id :string(36) # # Indexes @@ -18,10 +18,6 @@ # index_sections_on_versionable_id (versionable_id) # sections_phase_id_idx (phase_id) # -# Foreign Keys -# -# fk_rails_... (phase_id => phases.id) -# class Section < ActiveRecord::Base diff --git a/app/models/stat.rb b/app/models/stat.rb index 32e823e..5245406 100644 --- a/app/models/stat.rb +++ b/app/models/stat.rb @@ -1,17 +1,16 @@ # frozen_string_literal: true - # == Schema Information # # Table name: stats # # id :integer not null, primary key -# count :bigint(8) default(0) +# count :integer default("0") # date :date not null -# details :text # type :string not null +# org_id :integer # created_at :datetime not null # updated_at :datetime not null -# org_id :integer +# details :text # class Stat < ActiveRecord::Base diff --git a/app/models/stat_created_plan.rb b/app/models/stat_created_plan.rb index 2eb8708..d0fdb17 100644 --- a/app/models/stat_created_plan.rb +++ b/app/models/stat_created_plan.rb @@ -1,17 +1,16 @@ # frozen_string_literal: true - # == Schema Information # # Table name: stats # # id :integer not null, primary key -# count :bigint(8) default(0) +# count :integer default("0") # date :date not null -# details :text # type :string not null +# org_id :integer # created_at :datetime not null # updated_at :datetime not null -# org_id :integer +# details :text # require "set" diff --git a/app/models/stat_joined_user.rb b/app/models/stat_joined_user.rb index 7c0e80f..35bf055 100644 --- a/app/models/stat_joined_user.rb +++ b/app/models/stat_joined_user.rb @@ -1,17 +1,16 @@ # frozen_string_literal: true - # == Schema Information # # Table name: stats # # id :integer not null, primary key -# count :bigint(8) default(0) +# count :integer default("0") # date :date not null -# details :text # type :string not null +# org_id :integer # created_at :datetime not null # updated_at :datetime not null -# org_id :integer +# details :text # class StatJoinedUser < Stat diff --git a/app/models/static_page.rb b/app/models/static_page.rb index 363a9c3..0171ee1 100644 --- a/app/models/static_page.rb +++ b/app/models/static_page.rb @@ -3,9 +3,9 @@ # Table name: static_pages # # id :integer not null, primary key -# in_navigation :boolean default(TRUE) # name :string not null # url :string not null +# in_navigation :boolean default("true") # created_at :datetime not null # updated_at :datetime not null # diff --git a/app/models/static_page_content.rb b/app/models/static_page_content.rb index 36c4800..2a9d165 100644 --- a/app/models/static_page_content.rb +++ b/app/models/static_page_content.rb @@ -3,23 +3,18 @@ # Table name: static_page_contents # # id :integer not null, primary key -# content :text # title :string +# content :text +# static_page_id :integer not null +# language_id :integer not null # created_at :datetime not null # updated_at :datetime not null -# language_id :integer not null -# static_page_id :integer not null # # Indexes # # index_static_page_contents_on_language_id (language_id) # index_static_page_contents_on_static_page_id (static_page_id) # -# Foreign Keys -# -# fk_rails_... (language_id => languages.id) -# fk_rails_... (static_page_id => static_pages.id) -# class StaticPageContent < ActiveRecord::Base belongs_to :static_page diff --git a/app/models/structured_answer.rb b/app/models/structured_answer.rb new file mode 100644 index 0000000..0bde9f3 --- /dev/null +++ b/app/models/structured_answer.rb @@ -0,0 +1,16 @@ +# == Schema Information +# +# Table name: structured_answers +# +# id :integer not null, primary key +# data :json +# answer_id :integer +# structured_data_schema_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +class StructuredAnswer < ActiveRecord::Base + belongs_to :answer + belongs_to :structured_data_schema +end diff --git a/app/models/structured_data_schema.rb b/app/models/structured_data_schema.rb new file mode 100644 index 0000000..fa22124 --- /dev/null +++ b/app/models/structured_data_schema.rb @@ -0,0 +1,20 @@ +# == Schema Information +# +# Table name: structured_data_schemas +# +# id :integer not null, primary key +# label :string +# name :string +# version :integer +# schema :json +# org_id :integer +# object :string +# created_at :datetime not null +# updated_at :datetime not null +# + +class StructuredDataSchema < ActiveRecord::Base + belongs_to :org + has_many :structured_answers + has_many :questions +end diff --git a/app/models/template.rb b/app/models/template.rb index 1981eb8..b079b0b 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -4,20 +4,20 @@ # Table name: templates # # id :integer not null, primary key -# archived :boolean -# customization_of :integer -# description :text -# is_default :boolean -# links :text -# locale :string -# published :boolean # title :string -# version :integer -# visibility :integer +# description :text +# published :boolean +# org_id :integer +# locale :string +# is_default :boolean # created_at :datetime # updated_at :datetime +# version :integer +# visibility :integer +# customization_of :integer # family_id :integer -# org_id :integer +# archived :boolean +# links :text # # Indexes # @@ -25,10 +25,6 @@ # templates_family_id_version_key (family_id,version) UNIQUE # templates_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (org_id => orgs.id) -# class Template < ActiveRecord::Base diff --git a/app/models/user.rb b/app/models/user.rb index dd3da72..7b7bbd0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,42 +1,41 @@ # frozen_string_literal: true - # == Schema Information # # Table name: users # # id :integer not null, primary key -# accept_terms :boolean -# active :boolean default(TRUE) -# api_token :string -# confirmation_sent_at :datetime -# confirmation_token :string -# confirmed_at :datetime -# current_sign_in_at :datetime -# current_sign_in_ip :string -# dmponline3 :boolean -# email :string(80) default(""), not null -# encrypted_password :string default("") # firstname :string -# invitation_accepted_at :datetime -# invitation_created_at :datetime -# invitation_sent_at :datetime -# invitation_token :string -# invited_by_type :string -# last_sign_in_at :datetime -# last_sign_in_ip :string -# other_organisation :string -# recovery_email :string -# remember_created_at :datetime -# reset_password_sent_at :datetime -# reset_password_token :string -# sign_in_count :integer default(0) # surname :string +# email :string(80) default(""), not null # created_at :datetime not null # updated_at :datetime not null -# department_id :integer -# invited_by_id :integer -# language_id :integer +# encrypted_password :string default("") +# reset_password_token :string +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default("0") +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string +# last_sign_in_ip :string +# confirmation_token :string +# confirmed_at :datetime +# confirmation_sent_at :datetime +# invitation_token :string +# invitation_created_at :datetime +# invitation_sent_at :datetime +# invitation_accepted_at :datetime +# other_organisation :string +# dmponline3 :boolean +# accept_terms :boolean # org_id :integer +# api_token :string +# invited_by_id :integer +# invited_by_type :string +# language_id :integer +# recovery_email :string +# active :boolean default("true") +# department_id :integer # # Indexes # @@ -44,12 +43,6 @@ # users_language_id_idx (language_id) # users_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (department_id => departments.id) -# fk_rails_... (language_id => languages.id) -# fk_rails_... (org_id => orgs.id) -# class User < ActiveRecord::Base diff --git a/app/models/user_identifier.rb b/app/models/user_identifier.rb index 7a15e12..c6ef5a3 100644 --- a/app/models/user_identifier.rb +++ b/app/models/user_identifier.rb @@ -6,19 +6,14 @@ # identifier :string # created_at :datetime # updated_at :datetime -# identifier_scheme_id :integer # user_id :integer +# identifier_scheme_id :integer # # Indexes # # user_identifiers_identifier_scheme_id_idx (identifier_scheme_id) # user_identifiers_user_id_idx (user_id) # -# Foreign Keys -# -# fk_rails_... (identifier_scheme_id => identifier_schemes.id) -# fk_rails_... (user_id => users.id) -# class UserIdentifier < ActiveRecord::Base include ValidationMessages diff --git a/db/migrate/20200120124150_create_structured_data_schemas.rb b/db/migrate/20200120124150_create_structured_data_schemas.rb new file mode 100644 index 0000000..2d41697 --- /dev/null +++ b/db/migrate/20200120124150_create_structured_data_schemas.rb @@ -0,0 +1,14 @@ +class CreateStructuredDataSchemas < ActiveRecord::Migration + def change + create_table :structured_data_schemas do |t| + t.string :label + t.string :name + t.integer :version + t.json :schema + t.integer :org_id + t.string :object + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20200120124811_create_structured_answers.rb b/db/migrate/20200120124811_create_structured_answers.rb new file mode 100644 index 0000000..326df97 --- /dev/null +++ b/db/migrate/20200120124811_create_structured_answers.rb @@ -0,0 +1,11 @@ +class CreateStructuredAnswers < ActiveRecord::Migration + def change + create_table :structured_answers do |t| + t.json :data + t.integer :answer_id + t.integer :structured_data_schema_id + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20200120134328_add_structured_to_questions.rb b/db/migrate/20200120134328_add_structured_to_questions.rb new file mode 100644 index 0000000..deceb99 --- /dev/null +++ b/db/migrate/20200120134328_add_structured_to_questions.rb @@ -0,0 +1,5 @@ +class AddStructuredToQuestions < ActiveRecord::Migration + def change + add_column :questions, :structured, :boolean, null: false, default: false + end +end diff --git a/db/migrate/20200120134348_add_schema_id_to_questions.rb b/db/migrate/20200120134348_add_schema_id_to_questions.rb new file mode 100644 index 0000000..971919b --- /dev/null +++ b/db/migrate/20200120134348_add_schema_id_to_questions.rb @@ -0,0 +1,5 @@ +class AddSchemaIdToQuestions < ActiveRecord::Migration + def change + add_column :questions, :schema_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 6c93ad6..7833b11 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190620144049) do +ActiveRecord::Schema.define(version: 20200120134348) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -288,6 +288,8 @@ t.boolean "option_comment_display", default: true t.boolean "modifiable" t.string "versionable_id", limit: 36 + t.boolean "structured", default: false, null: false + t.integer "schema_id" end add_index "questions", ["question_format_id"], name: "questions_question_format_id_idx", using: :btree @@ -410,6 +412,25 @@ t.text "details" end + create_table "structured_answers", force: :cascade do |t| + t.json "data" + t.integer "answer_id" + t.integer "structured_data_schema_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "structured_data_schemas", force: :cascade do |t| + t.string "label" + t.string "name" + t.integer "version" + t.json "schema" + t.integer "org_id" + t.string "object" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "templates", force: :cascade do |t| t.string "title" t.text "description" diff --git a/spec/factories/annotations.rb b/spec/factories/annotations.rb index b9eee90..557384e 100644 --- a/spec/factories/annotations.rb +++ b/spec/factories/annotations.rb @@ -3,12 +3,12 @@ # Table name: annotations # # id :integer not null, primary key +# question_id :integer +# org_id :integer # text :text -# type :integer default(0), not null +# type :integer default("0"), not null # created_at :datetime # updated_at :datetime -# org_id :integer -# question_id :integer # versionable_id :string(36) # # Indexes @@ -17,11 +17,6 @@ # annotations_question_id_idx (question_id) # index_annotations_on_versionable_id (versionable_id) # -# Foreign Keys -# -# fk_rails_... (org_id => orgs.id) -# fk_rails_... (question_id => questions.id) -# FactoryBot.define do factory :annotation do diff --git a/spec/factories/answers.rb b/spec/factories/answers.rb index cf15b45..736addd 100644 --- a/spec/factories/answers.rb +++ b/spec/factories/answers.rb @@ -3,15 +3,15 @@ # Table name: answers # # id :integer not null, primary key -# is_common :boolean default(FALSE) -# lock_version :integer default(0) # text :text +# plan_id :integer +# user_id :integer +# question_id :integer # created_at :datetime # updated_at :datetime -# plan_id :integer -# question_id :integer +# lock_version :integer default("0") +# is_common :boolean default("false") # research_output_id :integer -# user_id :integer # # Indexes # @@ -20,13 +20,6 @@ # answers_user_id_idx (user_id) # index_answers_on_research_output_id (research_output_id) # -# Foreign Keys -# -# fk_rails_... (plan_id => plans.id) -# fk_rails_... (question_id => questions.id) -# fk_rails_... (research_output_id => research_outputs.id) -# fk_rails_... (user_id => users.id) -# FactoryBot.define do factory :answer do diff --git a/spec/factories/guidance_groups.rb b/spec/factories/guidance_groups.rb index affbef4..d5a8edf 100644 --- a/spec/factories/guidance_groups.rb +++ b/spec/factories/guidance_groups.rb @@ -4,20 +4,16 @@ # # id :integer not null, primary key # name :string -# optional_subset :boolean default(FALSE), not null -# published :boolean default(FALSE), not null +# org_id :integer # created_at :datetime not null # updated_at :datetime not null -# org_id :integer +# optional_subset :boolean default("false"), not null +# published :boolean default("false"), not null # # Indexes # # guidance_groups_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (org_id => orgs.id) -# FactoryBot.define do factory :guidance_group do diff --git a/spec/factories/guidances.rb b/spec/factories/guidances.rb index a2913f3..d8fd4f0 100644 --- a/spec/factories/guidances.rb +++ b/spec/factories/guidances.rb @@ -3,20 +3,16 @@ # Table name: guidances # # id :integer not null, primary key -# published :boolean # text :text +# guidance_group_id :integer # created_at :datetime not null # updated_at :datetime not null -# guidance_group_id :integer +# published :boolean # # Indexes # # guidances_guidance_group_id_idx (guidance_group_id) # -# Foreign Keys -# -# fk_rails_... (guidance_group_id => guidance_groups.id) -# FactoryBot.define do factory :guidance do diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb index 96a7c59..168ad36 100644 --- a/spec/factories/notes.rb +++ b/spec/factories/notes.rb @@ -3,24 +3,19 @@ # Table name: notes # # id :integer not null, primary key -# archived :boolean default(FALSE), not null -# archived_by :integer +# user_id :integer # text :text +# archived :boolean default("false"), not null +# answer_id :integer +# archived_by :integer # created_at :datetime # updated_at :datetime -# answer_id :integer -# user_id :integer # # Indexes # # notes_answer_id_idx (answer_id) # notes_user_id_idx (user_id) # -# Foreign Keys -# -# fk_rails_... (answer_id => answers.id) -# fk_rails_... (user_id => users.id) -# FactoryBot.define do factory :note do diff --git a/spec/factories/org_identifiers.rb b/spec/factories/org_identifiers.rb index 0ecba86..0b81367 100644 --- a/spec/factories/org_identifiers.rb +++ b/spec/factories/org_identifiers.rb @@ -3,23 +3,18 @@ # Table name: org_identifiers # # id :integer not null, primary key -# attrs :string # identifier :string +# attrs :string # created_at :datetime # updated_at :datetime -# identifier_scheme_id :integer # org_id :integer +# identifier_scheme_id :integer # # Indexes # # org_identifiers_identifier_scheme_id_idx (identifier_scheme_id) # org_identifiers_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (identifier_scheme_id => identifier_schemes.id) -# fk_rails_... (org_id => orgs.id) -# FactoryBot.define do factory :org_identifier do diff --git a/spec/factories/orgs.rb b/spec/factories/orgs.rb index 9e2d11c..bfdaeac 100644 --- a/spec/factories/orgs.rb +++ b/spec/factories/orgs.rb @@ -3,36 +3,31 @@ # Table name: orgs # # id :integer not null, primary key -# abbreviation :string -# banner_text :text -# contact_email :string -# contact_name :string -# feedback_email_msg :text -# feedback_email_subject :string -# feedback_enabled :boolean default(FALSE) -# is_other :boolean default(FALSE), not null -# links :text -# logo_name :string -# logo_uid :string # name :string -# org_type :integer default(0), not null -# sort_name :string +# abbreviation :string # target_url :string # created_at :datetime not null # updated_at :datetime not null -# language_id :integer +# is_other :boolean default("false"), not null +# sort_name :string +# banner_text :text # region_id :integer +# language_id :integer +# logo_uid :string +# logo_name :string +# contact_email :string +# org_type :integer default("0"), not null +# links :text +# contact_name :string +# feedback_enabled :boolean default("false") +# feedback_email_subject :string +# feedback_email_msg :text # # Indexes # # orgs_language_id_idx (language_id) # orgs_region_id_idx (region_id) # -# Foreign Keys -# -# fk_rails_... (language_id => languages.id) -# fk_rails_... (region_id => regions.id) -# FactoryBot.define do factory :org do diff --git a/spec/factories/phases.rb b/spec/factories/phases.rb index f9676b1..036c0a2 100644 --- a/spec/factories/phases.rb +++ b/spec/factories/phases.rb @@ -3,13 +3,13 @@ # Table name: phases # # id :integer not null, primary key -# description :text -# modifiable :boolean -# number :integer # title :string +# description :text +# number :integer +# template_id :integer # created_at :datetime # updated_at :datetime -# template_id :integer +# modifiable :boolean # versionable_id :string(36) # # Indexes @@ -17,10 +17,6 @@ # index_phases_on_versionable_id (versionable_id) # phases_template_id_idx (template_id) # -# Foreign Keys -# -# fk_rails_... (template_id => templates.id) -# FactoryBot.define do factory :phase do diff --git a/spec/factories/plans.rb b/spec/factories/plans.rb index 965612e..af3bc6e 100644 --- a/spec/factories/plans.rb +++ b/spec/factories/plans.rb @@ -3,33 +3,29 @@ # Table name: plans # # id :integer not null, primary key -# complete :boolean default(FALSE) -# data_contact :string -# data_contact_email :string -# data_contact_phone :string -# description :text -# feedback_requested :boolean default(FALSE) -# funder_name :string -# grant_number :string -# identifier :string -# principal_investigator :string -# principal_investigator_email :string -# principal_investigator_identifier :string -# principal_investigator_phone :string # title :string -# visibility :integer default(3), not null +# template_id :integer # created_at :datetime # updated_at :datetime -# template_id :integer +# grant_number :string +# identifier :string +# description :text +# principal_investigator :string +# principal_investigator_identifier :string +# data_contact :string +# funder_name :string +# visibility :integer default("3"), not null +# data_contact_email :string +# data_contact_phone :string +# principal_investigator_email :string +# principal_investigator_phone :string +# feedback_requested :boolean default("false") +# complete :boolean default("false") # # Indexes # # plans_template_id_idx (template_id) # -# Foreign Keys -# -# fk_rails_... (template_id => templates.id) -# FactoryBot.define do factory :plan do diff --git a/spec/factories/question_formats.rb b/spec/factories/question_formats.rb index 6b01a84..3e67daf 100644 --- a/spec/factories/question_formats.rb +++ b/spec/factories/question_formats.rb @@ -3,12 +3,12 @@ # Table name: question_formats # # id :integer not null, primary key -# description :text -# formattype :integer default(0) -# option_based :boolean default(FALSE) # title :string +# description :text # created_at :datetime not null # updated_at :datetime not null +# option_based :boolean default("false") +# formattype :integer default("0") # FactoryBot.define do diff --git a/spec/factories/question_options.rb b/spec/factories/question_options.rb index 4875d37..8d7acd1 100644 --- a/spec/factories/question_options.rb +++ b/spec/factories/question_options.rb @@ -3,21 +3,17 @@ # Table name: question_options # # id :integer not null, primary key -# is_default :boolean -# number :integer +# question_id :integer # text :string +# number :integer +# is_default :boolean # created_at :datetime # updated_at :datetime -# question_id :integer # # Indexes # # question_options_question_id_idx (question_id) # -# Foreign Keys -# -# fk_rails_... (question_id => questions.id) -# FactoryBot.define do factory :question_option do diff --git a/spec/factories/questions.rb b/spec/factories/questions.rb index 2ebfd4b..2e545d6 100644 --- a/spec/factories/questions.rb +++ b/spec/factories/questions.rb @@ -3,16 +3,18 @@ # Table name: questions # # id :integer not null, primary key -# default_value :text -# modifiable :boolean -# number :integer -# option_comment_display :boolean default(TRUE) # text :text +# default_value :text +# number :integer +# section_id :integer # created_at :datetime # updated_at :datetime # question_format_id :integer -# section_id :integer +# option_comment_display :boolean default("true") +# modifiable :boolean # versionable_id :string(36) +# structured :boolean default("false"), not null +# schema_id :integer # # Indexes # @@ -20,11 +22,6 @@ # questions_question_format_id_idx (question_format_id) # questions_section_id_idx (section_id) # -# Foreign Keys -# -# fk_rails_... (question_format_id => question_formats.id) -# fk_rails_... (section_id => sections.id) -# FactoryBot.define do factory :question do diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index 8bf3785..60afe70 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -3,23 +3,18 @@ # Table name: roles # # id :integer not null, primary key -# access :integer default(0), not null -# active :boolean default(FALSE) +# user_id :integer +# plan_id :integer # created_at :datetime # updated_at :datetime -# plan_id :integer -# user_id :integer +# access :integer default("0"), not null +# active :boolean default("false") # # Indexes # # roles_plan_id_idx (plan_id) # roles_user_id_idx (user_id) # -# Foreign Keys -# -# fk_rails_... (plan_id => plans.id) -# fk_rails_... (user_id => users.id) -# FactoryBot.define do factory :role do diff --git a/spec/factories/sections.rb b/spec/factories/sections.rb index c1d3b0e..4f0cbcc 100644 --- a/spec/factories/sections.rb +++ b/spec/factories/sections.rb @@ -3,13 +3,13 @@ # Table name: sections # # id :integer not null, primary key -# description :text -# modifiable :boolean -# number :integer # title :string +# description :text +# number :integer # created_at :datetime # updated_at :datetime # phase_id :integer +# modifiable :boolean # versionable_id :string(36) # # Indexes @@ -17,10 +17,6 @@ # index_sections_on_versionable_id (versionable_id) # sections_phase_id_idx (phase_id) # -# Foreign Keys -# -# fk_rails_... (phase_id => phases.id) -# FactoryBot.define do factory :section do diff --git a/spec/factories/structured_answers.rb b/spec/factories/structured_answers.rb new file mode 100644 index 0000000..cc2ecc1 --- /dev/null +++ b/spec/factories/structured_answers.rb @@ -0,0 +1,19 @@ +# == Schema Information +# +# Table name: structured_answers +# +# id :integer not null, primary key +# data :json +# answer_id :integer +# structured_data_schema_id :integer +# created_at :datetime not null +# updated_at :datetime not null +# + +FactoryBot.define do + factory :structured_answer do + data { "" } + answer_id { 1 } + schema_id { 1 } + end +end diff --git a/spec/factories/structured_data_schemas.rb b/spec/factories/structured_data_schemas.rb new file mode 100644 index 0000000..690bc45 --- /dev/null +++ b/spec/factories/structured_data_schemas.rb @@ -0,0 +1,25 @@ +# == Schema Information +# +# Table name: structured_data_schemas +# +# id :integer not null, primary key +# label :string +# name :string +# version :integer +# schema :json +# org_id :integer +# object :string +# created_at :datetime not null +# updated_at :datetime not null +# + +FactoryBot.define do + factory :structured_data_schema do + label { "MyString" } + name { "MyString" } + version { 1 } + schema { "" } + org_id { 1 } + object { "MyString" } + end +end diff --git a/spec/factories/templates.rb b/spec/factories/templates.rb index d6d5c83..ff75825 100644 --- a/spec/factories/templates.rb +++ b/spec/factories/templates.rb @@ -3,20 +3,20 @@ # Table name: templates # # id :integer not null, primary key -# archived :boolean -# customization_of :integer -# description :text -# is_default :boolean -# links :text -# locale :string -# published :boolean # title :string -# version :integer -# visibility :integer +# description :text +# published :boolean +# org_id :integer +# locale :string +# is_default :boolean # created_at :datetime # updated_at :datetime +# version :integer +# visibility :integer +# customization_of :integer # family_id :integer -# org_id :integer +# archived :boolean +# links :text # # Indexes # @@ -24,10 +24,6 @@ # templates_family_id_version_key (family_id,version) UNIQUE # templates_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (org_id => orgs.id) -# FactoryBot.define do factory :template do diff --git a/spec/factories/user_identifiers.rb b/spec/factories/user_identifiers.rb index e2c0e5b..628d9b2 100644 --- a/spec/factories/user_identifiers.rb +++ b/spec/factories/user_identifiers.rb @@ -6,19 +6,14 @@ # identifier :string # created_at :datetime # updated_at :datetime -# identifier_scheme_id :integer # user_id :integer +# identifier_scheme_id :integer # # Indexes # # user_identifiers_identifier_scheme_id_idx (identifier_scheme_id) # user_identifiers_user_id_idx (user_id) # -# Foreign Keys -# -# fk_rails_... (identifier_scheme_id => identifier_schemes.id) -# fk_rails_... (user_id => users.id) -# FactoryBot.define do factory :user_identifier do diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 150c2e0..9d323c3 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,42 +1,41 @@ # frozen_string_literal: true - # == Schema Information # # Table name: users # # id :integer not null, primary key -# accept_terms :boolean -# active :boolean default(TRUE) -# api_token :string -# confirmation_sent_at :datetime -# confirmation_token :string -# confirmed_at :datetime -# current_sign_in_at :datetime -# current_sign_in_ip :string -# dmponline3 :boolean -# email :string(80) default(""), not null -# encrypted_password :string default("") # firstname :string -# invitation_accepted_at :datetime -# invitation_created_at :datetime -# invitation_sent_at :datetime -# invitation_token :string -# invited_by_type :string -# last_sign_in_at :datetime -# last_sign_in_ip :string -# other_organisation :string -# recovery_email :string -# remember_created_at :datetime -# reset_password_sent_at :datetime -# reset_password_token :string -# sign_in_count :integer default(0) # surname :string +# email :string(80) default(""), not null # created_at :datetime not null # updated_at :datetime not null -# department_id :integer -# invited_by_id :integer -# language_id :integer +# encrypted_password :string default("") +# reset_password_token :string +# reset_password_sent_at :datetime +# remember_created_at :datetime +# sign_in_count :integer default("0") +# current_sign_in_at :datetime +# last_sign_in_at :datetime +# current_sign_in_ip :string +# last_sign_in_ip :string +# confirmation_token :string +# confirmed_at :datetime +# confirmation_sent_at :datetime +# invitation_token :string +# invitation_created_at :datetime +# invitation_sent_at :datetime +# invitation_accepted_at :datetime +# other_organisation :string +# dmponline3 :boolean +# accept_terms :boolean # org_id :integer +# api_token :string +# invited_by_id :integer +# invited_by_type :string +# language_id :integer +# recovery_email :string +# active :boolean default("true") +# department_id :integer # # Indexes # @@ -44,12 +43,6 @@ # users_language_id_idx (language_id) # users_org_id_idx (org_id) # -# Foreign Keys -# -# fk_rails_... (department_id => departments.id) -# fk_rails_... (language_id => languages.id) -# fk_rails_... (org_id => orgs.id) -# FactoryBot.define do factory :user do diff --git a/spec/models/structured_answer_spec.rb b/spec/models/structured_answer_spec.rb new file mode 100644 index 0000000..d6b87f1 --- /dev/null +++ b/spec/models/structured_answer_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe StructuredAnswer, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/structured_data_schema_spec.rb b/spec/models/structured_data_schema_spec.rb new file mode 100644 index 0000000..6e7886a --- /dev/null +++ b/spec/models/structured_data_schema_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe StructuredDataSchema, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end