1 """convert quantity from integer to float
2
3 Revision ID: 263dd6707191
4 Revises: 6b0f5f32d602
5 Create Date: 2022-03-23 17:43:34.727829
6
7 """
8
9 import sqlalchemy as sa 1 ctx 1a
10
11 from alembic import op 1 ctx 1a
12
13 # revision identifiers, used by Alembic.
14 revision = "263dd6707191" 1 ctx 1a
15 down_revision = "6b0f5f32d602" 1 ctx 1a
16 branch_labels : str | tuple [ str , ... ] | None = None 1 ctx 1a
17 depends_on : str | tuple [ str , ... ] | None = None 1 ctx 1a
18
19
20 def is_postgres ( ) : 1 ctx 1a
21 return op . get_context ( ) . dialect . name == "postgresql" 1 ctx 1a
22
23
24 def upgrade ( ) : 1 ctx 1a
25 # ### commands auto generated by Alembic - please adjust! ###
26
27 # SQLite doesn't require migration as types are not enforced.
28 # Postgres Specific Migration
29 if is_postgres ( ) : 29 ↛ 30 line 29 didn't jump to line 30 because the condition on line 29 was never true 1 ctx 1a
30 op . alter_column (
31 "recipes_ingredients" ,
32 "quantity" ,
33 type_ = sa . Float ( ) ,
34 existing_type = sa . Integer ( ) ,
35 )
36 # ### end Alembic commands ###
37
38
39 def downgrade ( ) : 1 ctx 1a
40 # ### commands auto generated by Alembic - please adjust! ###
41
42 # SQLite doesn't require migration as types are not enforced.
43 # Postgres Specific Migration
44 if is_postgres ( ) :
45 op . alter_column (
46 "recipes_ingredients" ,
47 "quantity" ,
48 type_ = sa . Integer ( ) ,
49 existing_type = sa . Float ( ) ,
50 )
51
52 # ### end Alembic commands ###