From 3426779dedb4fdc6afcc0091b9ca2b95b8599ed6 Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Tue, 9 Jan 2018 17:21:30 +0100 Subject: Change patchset column to string When running zuul with Github the sql reporter fails when trying to report data [1]. The reason for this is that github uses the git sha of the PR head as patchset which is no integer. Thus we must change this column to string. [1] Error message: sqlalchemy.exc.DataError: (psycopg2.DataError) invalid input syntax for integer: "fa42019a0d4f2a4a99ed6704c3fd037b7812e08f" LINE 1: ...b56049945e792082', 'check', 'foo/bar', 2, 'fa42019a0... Change-Id: I26ff56159c2710af1515955d27bf4e9ebfcf76e9 --- .../cfc0dc45f341_change_patchset_to_string.py | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 zuul/driver/sql/alembic/versions/cfc0dc45f341_change_patchset_to_string.py diff --git a/zuul/driver/sql/alembic/versions/cfc0dc45f341_change_patchset_to_string.py b/zuul/driver/sql/alembic/versions/cfc0dc45f341_change_patchset_to_string.py new file mode 100644 index 000000000..3fde8e545 --- /dev/null +++ b/zuul/driver/sql/alembic/versions/cfc0dc45f341_change_patchset_to_string.py @@ -0,0 +1,30 @@ +"""Change patchset to string + +Revision ID: cfc0dc45f341 +Revises: ba4cdce9b18c +Create Date: 2018-01-09 16:44:31.506958 + +""" + +# revision identifiers, used by Alembic. +revision = 'cfc0dc45f341' +down_revision = 'ba4cdce9b18c' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + +BUILDSET_TABLE = 'zuul_buildset' + + +def upgrade(table_prefix=''): + op.alter_column(table_prefix + BUILDSET_TABLE, + 'patchset', + sa.String(255), + existing_nullable=True, + existing_type=sa.Integer) + + +def downgrade(): + raise Exception("Downgrades not supported") -- cgit v1.2.1