aboutsummaryrefslogtreecommitdiffstats
path: root/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'migrations')
-rw-r--r--migrations/versions/1721493967-787116206e6d_add_form_question_models.py160
-rw-r--r--migrations/versions/1721564095-bef2f206168e_link_form_questions_to_forms.py36
2 files changed, 196 insertions, 0 deletions
diff --git a/migrations/versions/1721493967-787116206e6d_add_form_question_models.py b/migrations/versions/1721493967-787116206e6d_add_form_question_models.py
new file mode 100644
index 0000000..17acd61
--- /dev/null
+++ b/migrations/versions/1721493967-787116206e6d_add_form_question_models.py
@@ -0,0 +1,160 @@
+"""
+Add form question models.
+
+Revision ID: 787116206e6d
+Revises: a9ea4b71d23a
+Create Date: 2024-07-20 16:46:07.590445+00:00
+"""
+
+import sqlalchemy as sa
+from alembic import op
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision = "787116206e6d"
+down_revision = "a9ea4b71d23a"
+branch_labels = None
+depends_on = None
+
+
+def upgrade() -> None:
+ """Apply this migration."""
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table(
+ "form_questions",
+ sa.Column("question_id", sa.Integer(), nullable=False),
+ sa.Column("name", sa.String(), nullable=False),
+ sa.Column("type", sa.String(), nullable=False),
+ sa.Column("required", sa.Boolean(), nullable=False),
+ sa.PrimaryKeyConstraint("question_id", name=op.f("form_questions_pk")),
+ )
+ op.create_table(
+ "form_checkbox_questions",
+ sa.Column("checkbox_question_id", sa.Integer(), nullable=False),
+ sa.Column("options", postgresql.ARRAY(sa.Text()), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["checkbox_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_checkbox_questions_checkbox_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("checkbox_question_id", name=op.f("form_checkbox_questions_pk")),
+ )
+ op.create_table(
+ "form_code_questions",
+ sa.Column("code_question_id", sa.Integer(), nullable=False),
+ sa.Column("language", sa.String(), nullable=False),
+ sa.Column("allow_failure", sa.Boolean(), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["code_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_code_questions_code_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("code_question_id", name=op.f("form_code_questions_pk")),
+ )
+ op.create_table(
+ "form_radio_questions",
+ sa.Column("radio_question_id", sa.Integer(), nullable=False),
+ sa.Column("options", postgresql.ARRAY(sa.Text()), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["radio_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_radio_questions_radio_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("radio_question_id", name=op.f("form_radio_questions_pk")),
+ )
+ op.create_table(
+ "form_range_questions",
+ sa.Column("range_question_id", sa.Integer(), nullable=False),
+ sa.Column("options", postgresql.ARRAY(sa.Text()), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["range_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_range_questions_range_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("range_question_id", name=op.f("form_range_questions_pk")),
+ )
+ op.create_table(
+ "form_section_questions",
+ sa.Column("section_question_id", sa.Integer(), nullable=False),
+ sa.Column("text", sa.String(), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["section_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_section_questions_section_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("section_question_id", name=op.f("form_section_questions_pk")),
+ )
+ op.create_table(
+ "form_select_questions",
+ sa.Column("select_question_id", sa.Integer(), nullable=False),
+ sa.Column("options", postgresql.ARRAY(sa.Text()), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["select_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_select_questions_select_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("select_question_id", name=op.f("form_select_questions_pk")),
+ )
+ op.create_table(
+ "form_text_questions",
+ sa.Column("text_question_id", sa.Integer(), nullable=False),
+ sa.Column("text_type", sa.Enum("SHORT_TEXT", "TEXT_AREA", name="texttype"), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["text_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_text_questions_text_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("text_question_id", name=op.f("form_text_questions_pk")),
+ )
+ op.create_table(
+ "form_timezone_questions",
+ sa.Column("timezone_question_id", sa.Integer(), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["timezone_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_timezone_questions_timezone_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("timezone_question_id", name=op.f("form_timezone_questions_pk")),
+ )
+ op.create_table(
+ "form_vote_questions",
+ sa.Column("range_question_id", sa.Integer(), nullable=False),
+ sa.Column("options", postgresql.ARRAY(sa.Text()), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["range_question_id"],
+ ["form_questions.question_id"],
+ name=op.f("form_vote_questions_range_question_id_form_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("range_question_id", name=op.f("form_vote_questions_pk")),
+ )
+ op.create_table(
+ "form_code_question_tests",
+ sa.Column("test_id", sa.Integer(), nullable=False),
+ sa.Column("code_question_id", sa.Integer(), nullable=False),
+ sa.Column("name", sa.String(), nullable=False),
+ sa.Column("code", sa.String(), nullable=False),
+ sa.ForeignKeyConstraint(
+ ["code_question_id"],
+ ["form_code_questions.code_question_id"],
+ name=op.f("form_code_question_tests_code_question_id_form_code_questions_fk"),
+ ),
+ sa.PrimaryKeyConstraint("test_id", name=op.f("form_code_question_tests_pk")),
+ )
+ # ### end Alembic commands ###
+
+
+def downgrade() -> None:
+ """Revert this migration."""
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_table("form_code_question_tests")
+ op.drop_table("form_vote_questions")
+ op.drop_table("form_timezone_questions")
+ op.drop_table("form_text_questions")
+ op.drop_table("form_select_questions")
+ op.drop_table("form_section_questions")
+ op.drop_table("form_range_questions")
+ op.drop_table("form_radio_questions")
+ op.drop_table("form_code_questions")
+ op.drop_table("form_checkbox_questions")
+ op.drop_table("form_questions")
+ # ### end Alembic commands ###
diff --git a/migrations/versions/1721564095-bef2f206168e_link_form_questions_to_forms.py b/migrations/versions/1721564095-bef2f206168e_link_form_questions_to_forms.py
new file mode 100644
index 0000000..e84ecf4
--- /dev/null
+++ b/migrations/versions/1721564095-bef2f206168e_link_form_questions_to_forms.py
@@ -0,0 +1,36 @@
+"""
+Link form questions to forms.
+
+Revision ID: bef2f206168e
+Revises: 787116206e6d
+Create Date: 2024-07-21 12:14:55.545648+00:00
+"""
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "bef2f206168e"
+down_revision = "787116206e6d"
+branch_labels = None
+depends_on = None
+
+
+def upgrade() -> None:
+ """Apply this migration."""
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.add_column("form_questions", sa.Column("form_id", sa.Integer(), nullable=False))
+ op.create_foreign_key(
+ op.f("form_questions_form_id_forms_fk"), "form_questions", "forms", ["form_id"], ["form_id"]
+ )
+ # ### end Alembic commands ###
+
+
+def downgrade() -> None:
+ """Revert this migration."""
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_constraint(
+ op.f("form_questions_form_id_forms_fk"), "form_questions", type_="foreignkey"
+ )
+ op.drop_column("form_questions", "form_id")
+ # ### end Alembic commands ###