Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit 2ce77b8c920db9699712aa3634027f975cc9c2e2
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Nov 20 12:18:34 2015 +0100
[frontend] fix bug in the psql stored procedure (status order)
---------------------------------------------------------------
...94e2b5_fix_stored_procudure_status_order_bug.py | 78 ++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git
a/frontend/coprs_frontend/alembic/versions/4b57794e2b5_fix_stored_procudure_status_order_bug.py
b/frontend/coprs_frontend/alembic/versions/4b57794e2b5_fix_stored_procudure_status_order_bug.py
new file mode 100644
index 0000000..8c145d6
--- /dev/null
+++
b/frontend/coprs_frontend/alembic/versions/4b57794e2b5_fix_stored_procudure_status_order_bug.py
@@ -0,0 +1,78 @@
+"""fix stored procudure (status order) bug
+
+Revision ID: 4b57794e2b5
+Revises: 19ca0c14096e
+Create Date: 2015-11-20 11:57:25.079854
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '4b57794e2b5'
+down_revision = '19ca0c14096e'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ query_functions = """
+CREATE OR REPLACE FUNCTION status_to_order (x integer)
+RETURNS integer AS $$ BEGIN
+ RETURN CASE WHEN x = 0 THEN 0
+ WHEN x = 3 THEN 1
+ WHEN x = 6 THEN 2
+ WHEN x = 7 THEN 3
+ WHEN x = 4 THEN 4
+ WHEN x = 1 THEN 5
+ WHEN x = 5 THEN 6
+ WHEN x = 2 THEN 7
+ ELSE x
+ END; END;
+ $$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION order_to_status (x integer)
+RETURNS integer AS $$ BEGIN
+ RETURN CASE WHEN x = 0 THEN 0
+ WHEN x = 1 THEN 3
+ WHEN x = 2 THEN 6
+ WHEN x = 3 THEN 7
+ WHEN x = 4 THEN 4
+ WHEN x = 5 THEN 1
+ WHEN x = 6 THEN 5
+ WHEN x = 7 THEN 2
+ ELSE x
+ END; END;
+ $$ LANGUAGE plpgsql;
+"""
+ op.execute(sa.text(query_functions))
+
+
+def downgrade():
+ query_functions = """
+CREATE OR REPLACE FUNCTION status_to_order (x integer)
+RETURNS integer AS $$ BEGIN
+ RETURN CASE WHEN x = 0 THEN 0
+ WHEN x = 3 THEN 1
+ WHEN x = 6 THEN 2
+ WHEN x = 7 THEN 3
+ WHEN x = 4 THEN 4
+ WHEN x = 1 THEN 5
+ WHEN x = 5 THEN 6
+ ELSE 1000
+ END; END;
+ $$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION order_to_status (x integer)
+RETURNS integer AS $$ BEGIN
+ RETURN CASE WHEN x = 0 THEN 0
+ WHEN x = 1 THEN 3
+ WHEN x = 2 THEN 6
+ WHEN x = 3 THEN 7
+ WHEN x = 4 THEN 4
+ WHEN x = 5 THEN 1
+ WHEN x = 6 THEN 5
+ ELSE 1000
+ END; END;
+ $$ LANGUAGE plpgsql;
+"""
+ op.execute(sa.text(query_functions))