29 lines
881 B
Python
29 lines
881 B
Python
"""create fruits table
|
|
Revision ID: 2a8c4f9e3b1d
|
|
Revises: 0001
|
|
Create Date: 2024-01-18 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 = '2a8c4f9e3b1d'
|
|
down_revision = '0001'
|
|
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('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('ix_fruits_name', 'fruits', ['name'], unique=True)
|
|
|
|
def downgrade():
|
|
op.drop_index('ix_fruits_name')
|
|
op.drop_table('fruits') |