33 lines
978 B
Python
33 lines
978 B
Python
"""create countrys table
|
|
|
|
Revision ID: b2c3d4e5f6g7
|
|
Revises:
|
|
Create Date: 2024-01-09 12:00:00.000000
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.sql import func
|
|
import uuid
|
|
|
|
# revision identifiers
|
|
revision = 'b2c3d4e5f6g7'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
def upgrade():
|
|
op.create_table(
|
|
'countrys',
|
|
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
|
|
sa.Column('name', sa.String(), nullable=False, unique=True, index=True),
|
|
sa.Column('code', sa.String(2)),
|
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
|
|
op.create_index('ix_countrys_name', 'countrys', ['name'], unique=True)
|
|
|
|
def downgrade():
|
|
op.drop_index('ix_countrys_name', 'countrys')
|
|
op.drop_table('countrys') |