From b8ed8759034e11224b019c4fd58ad5d18af56010 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 31 Jul 2023 12:10:22 -0600 Subject: [PATCH] models.Run: Index the name column Signed-off-by: Zack Cerza --- .../versions/266e6f3efd94_index_run_name.py | 21 +++++++++++++++++++ paddles/models/runs.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 alembic/versions/266e6f3efd94_index_run_name.py diff --git a/alembic/versions/266e6f3efd94_index_run_name.py b/alembic/versions/266e6f3efd94_index_run_name.py new file mode 100644 index 0000000..6eb482e --- /dev/null +++ b/alembic/versions/266e6f3efd94_index_run_name.py @@ -0,0 +1,21 @@ +"""Index Run.name + +Revision ID: 266e6f3efd94 +Revises: 11e2594da07b +Create Date: 2023-07-31 12:01:24.936988 + +""" + +# revision identifiers, used by Alembic. +revision = '266e6f3efd94' +down_revision = '11e2594da07b' + +from alembic import op + + +def upgrade(): + op.create_index('ix_runs_name', 'runs', ['name'], unique=True) + + +def downgrade(): + op.drop_index('ix_runs_name', table_name='runs') diff --git a/paddles/models/runs.py b/paddles/models/runs.py index d90514a..0e2a620 100644 --- a/paddles/models/runs.py +++ b/paddles/models/runs.py @@ -102,7 +102,7 @@ class Run(Base): __tablename__ = 'runs' id = Column(Integer, primary_key=True) - name = Column(String(512), unique=True) + name = Column(String(512), index=True, unique=True) status = Column(String(16), index=True) user = Column(String(32), index=True) scheduled = Column(DateTime, index=True)