Add migration for Country
This commit is contained in:
parent
ac0ab2d61c
commit
1a2d0e3fcb
41
alembic/versions/20250326_125955_3aa0bbdc_create_country.py
Normal file
41
alembic/versions/20250326_125955_3aa0bbdc_create_country.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
"""create countrys table
|
||||||
|
|
||||||
|
Revision ID: a2b3c4d5e6f7
|
||||||
|
Revises:
|
||||||
|
Create Date: 2024-01-09 10:00:00.000000
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import func
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
# revision identifiers
|
||||||
|
revision = 'a2b3c4d5e6f7'
|
||||||
|
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, index=True),
|
||||||
|
sa.Column('iso2', sa.String(2)),
|
||||||
|
sa.Column('iso3', sa.String(3)),
|
||||||
|
sa.Column('capital', sa.String()),
|
||||||
|
sa.Column('region', sa.String()),
|
||||||
|
sa.Column('subregion', sa.String()),
|
||||||
|
sa.Column('population', sa.String()),
|
||||||
|
sa.Column('latitude', sa.String()),
|
||||||
|
sa.Column('longitude', sa.String()),
|
||||||
|
sa.Column('flag', sa.String()),
|
||||||
|
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=False)
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_index('ix_countrys_name', 'countrys')
|
||||||
|
op.drop_table('countrys')
|
Loading…
x
Reference in New Issue
Block a user