diff options
Diffstat (limited to 'migrations')
| -rw-r--r-- | migrations/versions/1721486482-a9ea4b71d23a_add_admins_forms.py | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/migrations/versions/1721486482-a9ea4b71d23a_add_admins_forms.py b/migrations/versions/1721486482-a9ea4b71d23a_add_admins_forms.py new file mode 100644 index 0000000..c61944b --- /dev/null +++ b/migrations/versions/1721486482-a9ea4b71d23a_add_admins_forms.py @@ -0,0 +1,93 @@ +""" +Add admins & forms. + +Revision ID: a9ea4b71d23a +Revises: +Create Date: 2024-07-20 14:41:22.166383+00:00 +""" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = "a9ea4b71d23a" +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade() -> None: + """Apply this migration.""" + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "admins", + sa.Column("user_id", sa.BigInteger(), nullable=False), + sa.PrimaryKeyConstraint("user_id", name=op.f("admins_pk")), + ) + op.create_table( + "forms", + sa.Column("form_id", sa.Integer(), nullable=False), + sa.Column("short_name", sa.Text(), nullable=False), + sa.Column("name", sa.Text(), nullable=False), + sa.Column("description", sa.Text(), nullable=False), + sa.Column("submission_text", sa.Text(), nullable=True), + sa.Column("webhook_url", sa.Text(), nullable=True), + sa.Column("webhook_message", sa.Text(), nullable=True), + sa.Column("discord_role", sa.BigInteger(), nullable=True), + sa.Column( + "features", + postgresql.ARRAY( + sa.Enum( + "DISCOVERABLE", + "REQUIRES_LOGIN", + "OPEN", + "COLLECT_EMAIL", + "DISABLE_ANTISPAM", + "WEBHOOK_ENABLED", + "ASSIGN_ROLE", + name="formfeatures", + ), + dimensions=1, + ), + nullable=False, + ), + sa.PrimaryKeyConstraint("form_id", name=op.f("forms_pk")), + ) + op.create_index(op.f("forms_short_name_ix"), "forms", ["short_name"], unique=False) + op.create_table( + "form_editors", + sa.Column("form_id", sa.Integer(), nullable=False), + sa.Column("user_id", sa.BigInteger(), nullable=False), + sa.ForeignKeyConstraint( + ["form_id"], + ["forms.form_id"], + name=op.f("form_editors_form_id_forms_fk"), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("form_id", "user_id", name=op.f("form_editors_pk")), + ) + op.create_table( + "form_response_readers", + sa.Column("form_id", sa.Integer(), nullable=False), + sa.Column("user_id", sa.BigInteger(), nullable=False), + sa.ForeignKeyConstraint( + ["form_id"], + ["forms.form_id"], + name=op.f("form_response_readers_form_id_forms_fk"), + ondelete="CASCADE", + ), + sa.PrimaryKeyConstraint("form_id", "user_id", name=op.f("form_response_readers_pk")), + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + """Revert this migration.""" + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table("form_response_readers") + op.drop_table("form_editors") + op.drop_index(op.f("forms_short_name_ix"), table_name="forms") + op.drop_table("forms") + op.drop_table("admins") + # ### end Alembic commands ### |