fooder-api/fooder/alembic/versions/564e5948f3ed_.py

71 lines
2.3 KiB
Python

"""
Revision ID: 564e5948f3ed
Revises: 4e8d78ff6e9e
Create Date: 2026-04-07 19:31:01.616100
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "564e5948f3ed"
down_revision: Union[str, Sequence[str], None] = "4e8d78ff6e9e"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f("ix_entry_meal_id"), "entry", ["meal_id"], unique=False)
op.create_index(op.f("ix_entry_product_id"), "entry", ["product_id"], unique=False)
op.drop_column("entry", "processed")
op.create_index(op.f("ix_meal_diary_id"), "meal", ["diary_id"], unique=False)
op.create_index(op.f("ix_preset_user_id"), "preset", ["user_id"], unique=False)
op.create_index(
op.f("ix_presetentry_preset_id"),
"presetentry",
["preset_id"],
unique=False,
)
op.create_index(
op.f("ix_presetentry_product_id"),
"presetentry",
["product_id"],
unique=False,
)
op.create_index(
"ix_userproductusage_product_user",
"userproductusage",
["product_id", "user_id"],
unique=False,
)
op.create_index(
op.f("ix_userproductusage_user_id"),
"userproductusage",
["user_id"],
unique=False,
)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_userproductusage_user_id"), table_name="userproductusage")
op.drop_index("ix_userproductusage_product_user", table_name="userproductusage")
op.drop_index(op.f("ix_presetentry_product_id"), table_name="presetentry")
op.drop_index(op.f("ix_presetentry_preset_id"), table_name="presetentry")
op.drop_index(op.f("ix_preset_user_id"), table_name="preset")
op.drop_index(op.f("ix_meal_diary_id"), table_name="meal")
op.add_column(
"entry",
sa.Column("processed", sa.BOOLEAN(), autoincrement=False, nullable=False),
)
op.drop_index(op.f("ix_entry_product_id"), table_name="entry")
op.drop_index(op.f("ix_entry_meal_id"), table_name="entry")
# ### end Alembic commands ###