From 22d6e34ae29649caaf942828c3d843905f1393aa Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Mon, 28 Apr 2025 15:55:44 +0000 Subject: [PATCH] fix: Handle existing contact_forms table in migration --- ...0428_142248_3d889e16_update_contact_form.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/alembic/versions/20250428_142248_3d889e16_update_contact_form.py b/alembic/versions/20250428_142248_3d889e16_update_contact_form.py index da8aebd..948af8a 100644 --- a/alembic/versions/20250428_142248_3d889e16_update_contact_form.py +++ b/alembic/versions/20250428_142248_3d889e16_update_contact_form.py @@ -13,13 +13,15 @@ branch_labels = None depends_on = None def upgrade(): - try: - op.add_column('contact_forms', sa.Column('name', sa.String(), nullable=False)) - op.add_column('contact_forms', sa.Column('message', sa.Text(), nullable=False)) - except sa.exc.OperationalError: - # Table already exists, do nothing - pass + op.create_table( + 'contact_forms', + sa.Column('id', sa.String(36), nullable=False, primary_key=True), + sa.Column('name', sa.String(), nullable=False), + sa.Column('email', sa.String(), nullable=False), + sa.Column('message', sa.Text(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.func.current_timestamp()), + sa.Column('updated_at', sa.DateTime(), nullable=False, server_default=sa.func.current_timestamp()) + ) def downgrade(): - op.drop_column('contact_forms', 'message') - op.drop_column('contact_forms', 'name') \ No newline at end of file + op.drop_table('contact_forms') \ No newline at end of file