From 0bd961ca8e940422fc549797be91130f76933b52 Mon Sep 17 00:00:00 2001 From: Nargis Sultani Date: Mon, 4 Dec 2023 10:51:34 -0500 Subject: [PATCH] adding modified alembic script --- ...612bf1c9_create_federal_regulator_table.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/db_revisions/versions/549c612bf1c9_create_federal_regulator_table.py b/db_revisions/versions/549c612bf1c9_create_federal_regulator_table.py index 964042c..f37f893 100644 --- a/db_revisions/versions/549c612bf1c9_create_federal_regulator_table.py +++ b/db_revisions/versions/549c612bf1c9_create_federal_regulator_table.py @@ -10,6 +10,8 @@ from alembic import op import sqlalchemy as sa +from db_revisions.utils import table_exists + # revision identifiers, used by Alembic. revision: str = "549c612bf1c9" @@ -19,14 +21,15 @@ def upgrade() -> None: - op.create_table( - "federal_regulator", - sa.Column("id", sa.String(length=4), nullable=False), - sa.Column("name", sa.String(), nullable=False), - sa.Column("event_time", sa.DateTime(), server_default=sa.text("now()"), nullable=False), - sa.PrimaryKeyConstraint("id"), - sa.UniqueConstraint("name"), - ) + if not table_exists("federal_regulator"): + op.create_table( + "federal_regulator", + sa.Column("id", sa.String(length=4), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.Column("event_time", sa.DateTime(), server_default=sa.func.now(), nullable=False), + sa.PrimaryKeyConstraint("id"), + sa.UniqueConstraint("name"), + ) def downgrade() -> None: