Merge "Add oldrev/newrev column to the buildset reporter table" into feature/zuulv3
diff --git a/tests/unit/test_connection.py b/tests/unit/test_connection.py
index 3774cc3..719f307 100644
--- a/tests/unit/test_connection.py
+++ b/tests/unit/test_connection.py
@@ -69,7 +69,7 @@
insp = sa.engine.reflection.Inspector(
self.connections.connections['resultsdb'].engine)
- self.assertEqual(11, len(insp.get_columns(buildset_table)))
+ self.assertEqual(13, len(insp.get_columns(buildset_table)))
self.assertEqual(10, len(insp.get_columns(build_table)))
def test_sql_results(self):
diff --git a/zuul/driver/sql/alembic_reporter/versions/ba4cdce9b18c_add_rev_columns.py b/zuul/driver/sql/alembic_reporter/versions/ba4cdce9b18c_add_rev_columns.py
new file mode 100644
index 0000000..a17dafd
--- /dev/null
+++ b/zuul/driver/sql/alembic_reporter/versions/ba4cdce9b18c_add_rev_columns.py
@@ -0,0 +1,26 @@
+"""Add oldrev/newrev columns
+
+Revision ID: ba4cdce9b18c
+Revises: 5efb477fa963
+Create Date: 2017-09-27 19:33:21.800198
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'ba4cdce9b18c'
+down_revision = '5efb477fa963'
+branch_labels = None
+depends_on = None
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ op.add_column('zuul_buildset', sa.Column('oldrev', sa.String(255)))
+ op.add_column('zuul_buildset', sa.Column('newrev', sa.String(255)))
+
+
+def downgrade():
+ op.drop_column('zuul_buildset', 'newrev')
+ op.drop_column('zuul_buildset', 'oldrev')
diff --git a/zuul/driver/sql/sqlconnection.py b/zuul/driver/sql/sqlconnection.py
index e0ccfba..b4e7a5f 100644
--- a/zuul/driver/sql/sqlconnection.py
+++ b/zuul/driver/sql/sqlconnection.py
@@ -91,6 +91,8 @@
sa.Column('change', sa.Integer, nullable=True),
sa.Column('patchset', sa.Integer, nullable=True),
sa.Column('ref', sa.String(255)),
+ sa.Column('oldrev', sa.String(255)),
+ sa.Column('newrev', sa.String(255)),
sa.Column('ref_url', sa.String(255)),
sa.Column('result', sa.String(255)),
sa.Column('message', sa.TEXT()),
diff --git a/zuul/driver/sql/sqlreporter.py b/zuul/driver/sql/sqlreporter.py
index 6a95212..7785c48 100644
--- a/zuul/driver/sql/sqlreporter.py
+++ b/zuul/driver/sql/sqlreporter.py
@@ -36,6 +36,8 @@
change = getattr(item.change, 'number', '')
patchset = getattr(item.change, 'patchset', '')
ref = getattr(item.change, 'ref', '')
+ oldrev = getattr(item.change, 'oldrev', '')
+ newrev = getattr(item.change, 'newrev', '')
buildset_ins = self.connection.zuul_buildset_table.insert().values(
zuul_ref=item.current_build_set.ref,
pipeline=item.pipeline.name,
@@ -43,6 +45,8 @@
change=change,
patchset=patchset,
ref=ref,
+ oldrev=oldrev,
+ newrev=newrev,
ref_url=item.change.url,
result=item.current_build_set.result,
message=self._formatItemReport(