Module d230af5e05d8_drop_unused_pg_only_db_functions
[hide private]
[frames] | no frames]

Source Code for Module d230af5e05d8_drop_unused_pg_only_db_functions

 1  """ 
 2  drop unused PG-only DB functions 
 3   
 4  Revision ID: d230af5e05d8 
 5  Revises: 4ed794df3bbb 
 6  Create Date: 2020-01-07 20:42:39.467075 
 7  """ 
 8   
 9  import sqlalchemy as sa 
10  from alembic import op 
11   
12   
13  revision = 'd230af5e05d8' 
14  down_revision = 'a8ef299dcac8' 
15   
16 -def upgrade():
17 query_functions = """ 18 DROP FUNCTION status_to_order; 19 DROP FUNCTION order_to_status; 20 """ 21 op.execute(sa.text(query_functions))
22
23 -def downgrade():
24 # copy from 465202bfb9ce_update_db_functions.py 25 query_functions = """ 26 CREATE OR REPLACE FUNCTION status_to_order (x integer) 27 RETURNS integer AS $$ BEGIN 28 RETURN CASE WHEN x = 3 THEN 1 29 WHEN x = 6 THEN 2 30 WHEN x = 7 THEN 3 31 WHEN x = 4 THEN 4 32 WHEN x = 0 THEN 5 33 WHEN x = 1 THEN 6 34 WHEN x = 5 THEN 7 35 WHEN x = 2 THEN 8 36 WHEN x = 8 THEN 9 37 WHEN x = 9 THEN 10 38 ELSE x 39 END; END; 40 $$ LANGUAGE plpgsql; 41 42 CREATE OR REPLACE FUNCTION order_to_status (x integer) 43 RETURNS integer AS $$ BEGIN 44 RETURN CASE WHEN x = 1 THEN 3 45 WHEN x = 2 THEN 6 46 WHEN x = 3 THEN 7 47 WHEN x = 4 THEN 4 48 WHEN x = 5 THEN 0 49 WHEN x = 6 THEN 1 50 WHEN x = 7 THEN 5 51 WHEN x = 8 THEN 2 52 WHEN x = 9 THEN 8 53 WHEN x = 10 THEN 9 54 ELSE x 55 END; END; 56 $$ LANGUAGE plpgsql; 57 """ 58 op.execute(sa.text(query_functions))
59