Coverage for opt/mealie/lib/python3.12/site-packages/mealie/alembic/versions/2024-09-18-14.52.55_1fe4bd37ccc8_add_households_filter_to_meal_plans.py: 76%

17 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 14:03 +0000

1"""add households filter to meal plans 

2 

3Revision ID: 1fe4bd37ccc8 

4Revises: be568e39ffdf 

5Create Date: 2024-09-18 14:52:55.831540 

6 

7""" 

8 

9import sqlalchemy as sa 1a

10from alembic import op 1a

11 

12import mealie.db.migration_types 1a

13 

14# revision identifiers, used by Alembic. 

15revision = "1fe4bd37ccc8" 1a

16down_revision: str | None = "be568e39ffdf" 1a

17branch_labels: str | tuple[str, ...] | None = None 1a

18depends_on: str | tuple[str, ...] | None = None 1a

19 

20 

21def upgrade(): 1a

22 # ### commands auto generated by Alembic - please adjust! ### 

23 op.create_table( 1a

24 "plan_rules_to_households", 

25 sa.Column("group_plan_rule_id", mealie.db.migration_types.GUID(), nullable=True), 

26 sa.Column("household_id", mealie.db.migration_types.GUID(), nullable=True), 

27 sa.ForeignKeyConstraint( 

28 ["group_plan_rule_id"], 

29 ["group_meal_plan_rules.id"], 

30 ), 

31 sa.ForeignKeyConstraint( 

32 ["household_id"], 

33 ["households.id"], 

34 ), 

35 sa.UniqueConstraint("group_plan_rule_id", "household_id", name="group_plan_rule_id_household_id_key"), 

36 ) 

37 with op.batch_alter_table("plan_rules_to_households", schema=None) as batch_op: 1a

38 batch_op.create_index( 1a

39 batch_op.f("ix_plan_rules_to_households_group_plan_rule_id"), ["group_plan_rule_id"], unique=False 

40 ) 

41 batch_op.create_index(batch_op.f("ix_plan_rules_to_households_household_id"), ["household_id"], unique=False) 1a

42 

43 # ### end Alembic commands ### 

44 

45 

46def downgrade(): 1a

47 # ### commands auto generated by Alembic - please adjust! ### 

48 with op.batch_alter_table("plan_rules_to_households", schema=None) as batch_op: 

49 batch_op.drop_index(batch_op.f("ix_plan_rules_to_households_household_id")) 

50 batch_op.drop_index(batch_op.f("ix_plan_rules_to_households_group_plan_rule_id")) 

51 

52 op.drop_table("plan_rules_to_households") 

53 # ### end Alembic commands ###