second-project-wahm3i/alembic/versions/20250413_202953_a7b1205a_update_car.py

28 lines
839 B
Python

"""create cars table
Revision ID: a1b2c3d4e5f6
Revises: 0002
Create Date: 2024-01-20 10:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'a7b1205a'
down_revision = '0002'
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'cars',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('name', sa.String(), nullable=False),
sa.Column('color', sa.String(), nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now())
)
op.create_index(op.f('ix_cars_name'), 'cars', ['name'], unique=False)
def downgrade():
op.drop_index(op.f('ix_cars_name'), table_name='cars')
op.drop_table('cars')