project-three-6eu16p/alembic/versions/20250428_134737_0265a0c8_update_contact_form.py

29 lines
1006 B
Python

"""add email_validator to contact_form table
Revision ID: 6be7c5a3ec33
Revises: 2b9e7c8a3f0e
Create Date: 2023-05-25 14:23:12.921283
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6be7c5a3ec33'
down_revision = '2b9e7c8a3f0e'
branch_labels = None
depends_on = None
def upgrade():
table_name = "contact_forms"
# SQLite does not support altering columns, so we need to recreate the table
op.create_table(
table_name,
sa.Column('id', sa.String(36), primary_key=True, nullable=False),
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(), server_default=sa.func.now(), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), nullable=False, onupdate=sa.func.now())
)
def downgrade():
op.drop_table('contact_forms')