1 """empty migration to fix food flag data
2
3 Revision ID: d7b3ce6fa31a
4 Revises: 7cf3054cbbcc
5 Create Date: 2025-07-11 20:17:10.543280
6
7 """
8
9 from textwrap import dedent 1 ctx 1a
10
11 from alembic import op 1 ctx 1a
12
13
14 # revision identifiers, used by Alembic.
15 revision = "d7b3ce6fa31a" 1 ctx 1a
16 down_revision : str | None = "7cf3054cbbcc" 1 ctx 1a
17 branch_labels : str | tuple [ str , ... ] | None = None 1 ctx 1a
18 depends_on : str | tuple [ str , ... ] | None = None 1 ctx 1a
19
20
21 def is_postgres ( ) : 1 ctx 1a
22 return op . get_context ( ) . dialect . name == "postgresql" 1 ctx 1a
23
24
25 def upgrade ( ) : 1 ctx 1a
26 # Update recipes with disable_amount=True: set ingredient quantities of 1 to 0
27 op . execute ( 1 ctx 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
44 def downgrade ( ) : 1 ctx 1a
45 pass