Coverage for opt/mealie/lib/python3.12/site-packages/mealie/alembic/versions/2025-07-11-20.17.10_d7b3ce6fa31a_empty_migration_to_fix_food_flag_data.py: 92%

12 statements  

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

1"""empty migration to fix food flag data 

2 

3Revision ID: d7b3ce6fa31a 

4Revises: 7cf3054cbbcc 

5Create Date: 2025-07-11 20:17:10.543280 

6 

7""" 

8 

9from textwrap import dedent 1a

10 

11from alembic import op 1a

12 

13 

14# revision identifiers, used by Alembic. 

15revision = "d7b3ce6fa31a" 1a

16down_revision: str | None = "7cf3054cbbcc" 1a

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

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

19 

20 

21def is_postgres(): 1a

22 return op.get_context().dialect.name == "postgresql" 1a

23 

24 

25def upgrade(): 1a

26 # Update recipes with disable_amount=True: set ingredient quantities of 1 to 0 

27 op.execute( 1a

28 dedent( 

29 f""" 

30 UPDATE recipes_ingredients 

31 SET quantity = 0 

32 WHERE quantity = 1 

33 AND recipe_id IN ( 

34 SELECT r.id 

35 FROM recipes r 

36 JOIN recipe_settings rs ON r.id = rs.recipe_id 

37 WHERE rs.disable_amount = {"true" if is_postgres() else "1"} 

38 ) 

39 """ 

40 ) 

41 ) 

42 

43 

44def downgrade(): 1a

45 pass