Add migration for Country
This commit is contained in:
parent
ba02e1712c
commit
047c624d1d
33
alembic/versions/20250325_135821_5fd9c777_create_country.py
Normal file
33
alembic/versions/20250325_135821_5fd9c777_create_country.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
"""create countrys table
|
||||||
|
|
||||||
|
Revision ID: 1234567890ab
|
||||||
|
Revises:
|
||||||
|
Create Date: 2023-06-07 10:00:00.000000
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic
|
||||||
|
revision = '1234567890ab'
|
||||||
|
down_revision = None
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_table(
|
||||||
|
'countrys',
|
||||||
|
sa.Column('id', UUID(as_uuid=True), primary_key=True),
|
||||||
|
sa.Column('name', sa.String, nullable=False, unique=True, index=True),
|
||||||
|
sa.Column('code', sa.String(3), nullable=False),
|
||||||
|
sa.Column('population', sa.Integer, nullable=False),
|
||||||
|
sa.Column('created_at', sa.Integer, server_default=sa.func.now()),
|
||||||
|
sa.Column('updated_at', sa.Integer, server_default=sa.func.now(), onupdate=sa.func.now())
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_table('countrys')
|
Loading…
x
Reference in New Issue
Block a user