fix: Handle existing contact_forms table in migration
This commit is contained in:
parent
3aed0277b9
commit
22d6e34ae2
@ -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')
|
||||
op.drop_table('contact_forms')
|
Loading…
x
Reference in New Issue
Block a user