diff --git a/tests/unit/test_connection.py b/tests/unit/test_connection.py index cef9c29495..85ad758bff 100644 --- a/tests/unit/test_connection.py +++ b/tests/unit/test_connection.py @@ -74,7 +74,7 @@ class TestSQLConnection(ZuulDBTestCase): buildset_table = table_prefix + 'zuul_buildset' build_table = table_prefix + 'zuul_build' - self.assertEqual(14, len(insp.get_columns(buildset_table))) + self.assertEqual(15, len(insp.get_columns(buildset_table))) self.assertEqual(10, len(insp.get_columns(build_table))) def test_sql_tables_created(self): diff --git a/zuul/driver/sql/alembic/versions/649ce63b5fe5_add_buildset_uuid.py b/zuul/driver/sql/alembic/versions/649ce63b5fe5_add_buildset_uuid.py new file mode 100644 index 0000000000..355b796344 --- /dev/null +++ b/zuul/driver/sql/alembic/versions/649ce63b5fe5_add_buildset_uuid.py @@ -0,0 +1,37 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Add uuid to buldset + +Revision ID: 649ce63b5fe5 +Revises: ea2bae776723 +Create Date: 2019-01-11 06:17:40.042738 + +""" + +# revision identifiers, used by Alembic. +revision = '649ce63b5fe5' +down_revision = 'ea2bae776723' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(table_prefix=''): + op.add_column( + table_prefix + 'zuul_buildset', sa.Column('uuid', sa.String(36))) + + +def downgrade(): + raise Exception("Downgrades not supported") diff --git a/zuul/driver/sql/sqlconnection.py b/zuul/driver/sql/sqlconnection.py index 8a9a0f0af9..1a0efb559c 100644 --- a/zuul/driver/sql/sqlconnection.py +++ b/zuul/driver/sql/sqlconnection.py @@ -176,6 +176,7 @@ class SQLConnection(BaseConnection): class BuildSetModel(Base): __tablename__ = self.table_prefix + BUILDSET_TABLE id = sa.Column(sa.Integer, primary_key=True) + uuid = sa.Column(sa.String(36)) zuul_ref = sa.Column(sa.String(255)) pipeline = sa.Column(sa.String(255)) project = sa.Column(sa.String(255)) diff --git a/zuul/driver/sql/sqlreporter.py b/zuul/driver/sql/sqlreporter.py index f545da00d3..1e148d623f 100644 --- a/zuul/driver/sql/sqlreporter.py +++ b/zuul/driver/sql/sqlreporter.py @@ -56,6 +56,7 @@ class SQLReporter(BaseReporter): with self.connection.getSession() as db: db_buildset = db.createBuildSet( + uuid=item.current_build_set.uuid, tenant=item.pipeline.tenant.name, pipeline=item.pipeline.name, project=item.change.project.name,