Add migration for Bird
This commit is contained in:
parent
c2515c776b
commit
9f764e7855
35
alembic/versions/20250327_031905_fb42e69d_create_bird.py
Normal file
35
alembic/versions/20250327_031905_fb42e69d_create_bird.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""create birds table
|
||||
|
||||
Revision ID: 1234567890ab
|
||||
Revises:
|
||||
Create Date: 2023-05-23 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(
|
||||
'birds',
|
||||
sa.Column('id', UUID(as_uuid=True), primary_key=True, server_default=sa.text("uuid_generate_v4()")),
|
||||
sa.Column('name', sa.String, nullable=False, unique=True),
|
||||
sa.Column('species', sa.String, nullable=False),
|
||||
sa.Column('description', sa.String),
|
||||
sa.Column('age', sa.Integer),
|
||||
sa.Column('created_at', UUID, sa.ForeignKey('created_at_metadata.id')),
|
||||
sa.Column('updated_at', UUID, sa.ForeignKey('updated_at_metadata.id')),
|
||||
sa.Index('ix_birds_name', 'name')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('birds')
|
Loading…
x
Reference in New Issue
Block a user