30 lines
946 B
Python
30 lines
946 B
Python
"""create fruits table
|
|
Revision ID: a1b2c3d4e5f6
|
|
Revises: 0002
|
|
Create Date: 2024-01-20 10:00:00.000000
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
import uuid
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '8c9c9d7b'
|
|
down_revision = '0002'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
def upgrade():
|
|
op.create_table(
|
|
'fruits',
|
|
sa.Column('id', postgresql.UUID(as_uuid=True), primary_key=True, default=uuid.uuid4),
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
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())
|
|
)
|
|
op.create_index(op.f('ix_fruits_name'), 'fruits', ['name'])
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_fruits_name'), 'fruits')
|
|
op.drop_table('fruits') |