38 lines
913 B
Python
38 lines
913 B
Python
"""Initial migration - Create items table
|
|
|
|
Revision ID: 001
|
|
Revises:
|
|
Create Date: 2023-09-14
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "001"
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create items table
|
|
op.create_table(
|
|
"items",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("title", sa.String(length=100), nullable=False),
|
|
sa.Column("description", sa.Text(), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_items_id"), "items", ["id"], unique=False)
|
|
op.create_index(op.f("ix_items_title"), "items", ["title"], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
# Drop items table
|
|
op.drop_index(op.f("ix_items_title"), table_name="items")
|
|
op.drop_index(op.f("ix_items_id"), table_name="items")
|
|
op.drop_table("items")
|