"""Create all tables Revision ID: cf94fca21104 Revises: Create Date: 2025-09-28 11:20:06.569885 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = 'cf94fca21104' down_revision: Union[str, None] = None branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('foods', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=True), sa.Column('serving_size', sa.String(), nullable=True), sa.Column('serving_unit', sa.String(), nullable=True), sa.Column('calories', sa.Float(), nullable=True), sa.Column('protein', sa.Float(), nullable=True), sa.Column('carbs', sa.Float(), nullable=True), sa.Column('fat', sa.Float(), nullable=True), sa.Column('fiber', sa.Float(), nullable=True), sa.Column('sugar', sa.Float(), nullable=True), sa.Column('sodium', sa.Float(), nullable=True), sa.Column('calcium', sa.Float(), nullable=True), sa.Column('source', sa.String(), nullable=True), sa.Column('brand', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_foods_id'), 'foods', ['id'], unique=False) op.create_index(op.f('ix_foods_name'), 'foods', ['name'], unique=True) op.create_table('meals', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=True), sa.Column('meal_type', sa.String(), nullable=True), sa.Column('meal_time', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_meals_id'), 'meals', ['id'], unique=False) op.create_index(op.f('ix_meals_name'), 'meals', ['name'], unique=False) op.create_table('meal_foods', sa.Column('id', sa.Integer(), nullable=False), sa.Column('meal_id', sa.Integer(), nullable=True), sa.Column('food_id', sa.Integer(), nullable=True), sa.Column('quantity', sa.Float(), nullable=True), sa.ForeignKeyConstraint(['food_id'], ['foods.id'], ), sa.ForeignKeyConstraint(['meal_id'], ['meals.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_meal_foods_id'), 'meal_foods', ['id'], unique=False) op.create_table('plans', sa.Column('id', sa.Integer(), nullable=False), sa.Column('person', sa.String(), nullable=True), sa.Column('date', sa.Date(), nullable=True), sa.Column('meal_id', sa.Integer(), nullable=True), sa.Column('meal_time', sa.String(), nullable=True), sa.ForeignKeyConstraint(['meal_id'], ['meals.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_plans_id'), 'plans', ['id'], unique=False) op.create_index(op.f('ix_plans_person'), 'plans', ['person'], unique=False) op.create_index(op.f('ix_plans_date'), 'plans', ['date'], unique=False) op.create_table('templates', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_templates_id'), 'templates', ['id'], unique=False) op.create_index(op.f('ix_templates_name'), 'templates', ['name'], unique=True) op.create_table('template_meals', sa.Column('id', sa.Integer(), nullable=False), sa.Column('template_id', sa.Integer(), nullable=True), sa.Column('meal_id', sa.Integer(), nullable=True), sa.Column('meal_time', sa.String(), nullable=True), sa.ForeignKeyConstraint(['meal_id'], ['meals.id'], ), sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_template_meals_id'), 'template_meals', ['id'], unique=False) op.create_table('weekly_menus', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_weekly_menus_id'), 'weekly_menus', ['id'], unique=False) op.create_index(op.f('ix_weekly_menus_name'), 'weekly_menus', ['name'], unique=True) op.create_table('weekly_menu_days', sa.Column('id', sa.Integer(), nullable=False), sa.Column('weekly_menu_id', sa.Integer(), nullable=True), sa.Column('day_of_week', sa.Integer(), nullable=True), sa.Column('template_id', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['template_id'], ['templates.id'], ), sa.ForeignKeyConstraint(['weekly_menu_id'], ['weekly_menus.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_weekly_menu_days_id'), 'weekly_menu_days', ['id'], unique=False) op.create_table('tracked_days', sa.Column('id', sa.Integer(), nullable=False), sa.Column('person', sa.String(), nullable=True), sa.Column('date', sa.Date(), nullable=True), sa.Column('is_modified', sa.Boolean(), nullable=True), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_tracked_days_id'), 'tracked_days', ['id'], unique=False) op.create_index(op.f('ix_tracked_days_person'), 'tracked_days', ['person'], unique=False) op.create_index(op.f('ix_tracked_days_date'), 'tracked_days', ['date'], unique=False) op.create_table('tracked_meals', sa.Column('id', sa.Integer(), nullable=False), sa.Column('tracked_day_id', sa.Integer(), nullable=True), sa.Column('meal_id', sa.Integer(), nullable=True), sa.Column('meal_time', sa.String(), nullable=True), sa.Column('quantity', sa.Float(), nullable=True), sa.ForeignKeyConstraint(['meal_id'], ['meals.id'], ), sa.ForeignKeyConstraint(['tracked_day_id'], ['tracked_days.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_tracked_meals_id'), 'tracked_meals', ['id'], unique=False) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_index(op.f('ix_tracked_meals_id'), table_name='tracked_meals') op.drop_table('tracked_meals') op.drop_index(op.f('ix_tracked_days_date'), table_name='tracked_days') op.drop_index(op.f('ix_tracked_days_person'), table_name='tracked_days') op.drop_index(op.f('ix_tracked_days_id'), table_name='tracked_days') op.drop_table('tracked_days') op.drop_index(op.f('ix_weekly_menu_days_id'), table_name='weekly_menu_days') op.drop_table('weekly_menu_days') op.drop_index(op.f('ix_weekly_menus_name'), table_name='weekly_menus') op.drop_index(op.f('ix_weekly_menus_id'), table_name='weekly_menus') op.drop_table('weekly_menus') op.drop_index(op.f('ix_template_meals_id'), table_name='template_meals') op.drop_table('template_meals') op.drop_index(op.f('ix_templates_name'), table_name='templates') op.drop_index(op.f('ix_templates_id'), table_name='templates') op.drop_table('templates') op.drop_index(op.f('ix_plans_date'), table_name='plans') op.drop_index(op.f('ix_plans_person'), table_name='plans') op.drop_index(op.f('ix_plans_id'), table_name='plans') op.drop_table('plans') op.drop_index(op.f('ix_meal_foods_id'), table_name='meal_foods') op.drop_table('meal_foods') op.drop_index(op.f('ix_meals_name'), table_name='meals') op.drop_index(op.f('ix_meals_id'), table_name='meals') op.drop_table('meals') op.drop_index(op.f('ix_foods_name'), table_name='foods') op.drop_index(op.f('ix_foods_id'), table_name='foods') op.drop_table('foods') # ### end Alembic commands ###