From ab0ad0174179a3be25209b86ac304170e7762fcb Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Mon, 30 Nov 2015 16:25:06 -0500 Subject: [PATCH] Fix indexes in db models The DB models didn't properly list all of the indexes on tables. This commit goes through all the tables with missing indexes on the model and updates it to make sure everything is up-to-date. Change-Id: Idcfe487ff4534e4477086897830909b9e6c117f6 --- subunit2sql/db/models.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/subunit2sql/db/models.py b/subunit2sql/db/models.py index e74a6b4..476e4e5 100644 --- a/subunit2sql/db/models.py +++ b/subunit2sql/db/models.py @@ -49,7 +49,10 @@ class SubunitBase(models.ModelBase): class Test(BASE, SubunitBase): __tablename__ = 'tests' - __table_args__ = (sa.Index('ix_test_id', 'test_id'),) + __table_args__ = (sa.Index('ix_test_ids', 'id', 'test_id', + mysql_length={'test_id': 30}), + sa.Index('ix_tests_test_id', 'test_id', + mysql_length=30)) id = sa.Column(sa.BigInteger, primary_key=True) test_id = sa.Column(sa.String(256)) run_count = sa.Column(sa.Integer()) @@ -60,7 +63,8 @@ class Test(BASE, SubunitBase): class Run(BASE, SubunitBase): __tablename__ = 'runs' - __table_args__ = (sa.Index('ix_run_at', 'run_at'),) + __table_args__ = (sa.Index('ix_run_at', 'run_at'), + sa.Index('ix_run_uuid', 'uuid')) uuid = sa.Column(sa.String(36), default=lambda: six.text_type(uuid.uuid4())) id = sa.Column(sa.BigInteger, primary_key=True) @@ -75,10 +79,15 @@ class Run(BASE, SubunitBase): class TestRun(BASE, SubunitBase): __tablename__ = 'test_runs' - __table_args__ = (sa.Index('ix_test_run_test_id', 'test_id'), - sa.Index('ix_test_run_run_id', 'run_id'), + __table_args__ = (sa.Index('ix_test_id_status', 'test_id', 'status'), + sa.Index('ix_test_id_start_time', 'test_id', + 'start_time'), + sa.Index('ix_test_runs_test_id', 'test_id'), + sa.Index('ix_test_runs_run_id', 'run_id'), + sa.Index('ix_test_runs_start_time', 'start_time'), + sa.Index('ix_test_runs_stop_time', 'stop_time'), sa.UniqueConstraint('test_id', 'run_id', - name='ix_test_run_test_id_run_id')) + name='uq_test_runs')) id = sa.Column(sa.BigInteger, primary_key=True) test_id = sa.Column(sa.BigInteger, sa.ForeignKey('tests.id'),