Skip to content

Commit

Permalink
Refactor migration to add forms model tables
Browse files Browse the repository at this point in the history
- Remove force: :cascade
- Use timestamps shortcut
- Use references shortcut
- Let Rails choose index name
  • Loading branch information
lfdebrux committed Jan 30, 2025
1 parent 8dac90c commit 7ed1762
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions db/migrate/20241230151100_add_forms.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AddForms < ActiveRecord::Migration[7.2]
def change
create_table "forms", force: :cascade do |t|
create_table "forms" do |t|
t.text "name"
t.text "submission_email"
t.text "privacy_policy_url"
Expand All @@ -12,9 +12,8 @@ def change
t.text "declaration_text"
t.boolean "question_section_completed", default: false
t.boolean "declaration_section_completed", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "creator_id"
t.timestamps
t.references :creator, index: false
t.text "what_happens_next_markdown"
t.string "state"
t.string "payment_url"
Expand All @@ -24,39 +23,31 @@ def change
t.string "s3_bucket_name"
t.string "s3_bucket_aws_account_id"
t.string "s3_bucket_region"
t.index ["external_id"], name: "index_forms_on_external_id", unique: true
t.index "external_id", unique: true
end

create_table "pages", force: :cascade do |t|
create_table "pages" do |t|
t.text "question_text"
t.text "hint_text"
t.text "answer_type"
t.integer "next_page"
t.boolean "is_optional", null: false
t.jsonb "answer_settings"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "form_id"
t.timestamps
t.references :form, foreign_key: true
t.integer "position"
t.text "page_heading"
t.text "guidance_markdown"
t.boolean "is_repeatable", default: false, null: false
t.index ["form_id"], name: "index_pages_on_form_id"
end

create_table "conditions", force: :cascade do |t|
t.bigint "check_page_id", comment: "The question page this condition looks at to compare answers"
t.bigint "routing_page_id", comment: "The question page at which this conditional route takes place"
t.bigint "goto_page_id", comment: "The question page which this conditions will skip forwards to"
create_table "conditions" do |t|
t.references :check_page, comment: "The question page this condition looks at to compare answers"
t.references :routing_page, comment: "The question page at which this conditional route takes place"
t.references :goto_page, comment: "The question page which this conditions will skip forwards to"
t.string "answer_value"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.timestamps
t.boolean "skip_to_end", default: false
t.index ["check_page_id"], name: "index_conditions_on_check_page_id"
t.index ["goto_page_id"], name: "index_conditions_on_goto_page_id"
t.index ["routing_page_id"], name: "index_conditions_on_routing_page_id"
end

add_foreign_key "pages", "forms"
end
end

0 comments on commit 7ed1762

Please sign in to comment.