From 3d44416016326565f4323fdaaa76ffa12a20d7d6 Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Mon, 23 Mar 2015 11:40:21 -0400 Subject: [PATCH] Add the migration for the unique index which helps prevent tag deadlocks. --- data/migrations/migration.sh | 8 +++--- ...dd_a_unique_index_to_prevent_deadlocks_.py | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 data/migrations/versions/2b4dc0818a5e_add_a_unique_index_to_prevent_deadlocks_.py diff --git a/data/migrations/migration.sh b/data/migrations/migration.sh index 17901e130..daae7e1f2 100755 --- a/data/migrations/migration.sh +++ b/data/migrations/migration.sh @@ -19,7 +19,7 @@ up_mysql() { down_mysql() { docker kill mysql - docker rm mysql + docker rm -v mysql } up_mariadb() { @@ -36,7 +36,7 @@ up_mariadb() { down_mariadb() { docker kill mariadb - docker rm mariadb + docker rm -v mariadb } up_percona() { @@ -53,7 +53,7 @@ up_percona() { down_percona() { docker kill percona - docker rm percona + docker rm -v percona } up_postgres() { @@ -70,7 +70,7 @@ up_postgres() { down_postgres() { docker kill postgres - docker rm postgres + docker rm -v postgres } gen_migrate() { diff --git a/data/migrations/versions/2b4dc0818a5e_add_a_unique_index_to_prevent_deadlocks_.py b/data/migrations/versions/2b4dc0818a5e_add_a_unique_index_to_prevent_deadlocks_.py new file mode 100644 index 000000000..8efe0c123 --- /dev/null +++ b/data/migrations/versions/2b4dc0818a5e_add_a_unique_index_to_prevent_deadlocks_.py @@ -0,0 +1,26 @@ +"""Add a unique index to prevent deadlocks with tags. + +Revision ID: 2b4dc0818a5e +Revises: 2b2529fd23ff +Create Date: 2015-03-20 23:37:10.558179 + +""" + +# revision identifiers, used by Alembic. +revision = '2b4dc0818a5e' +down_revision = '2b2529fd23ff' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.create_index('repositorytag_repository_id_name_lifetime_end_ts', 'repositorytag', ['repository_id', 'name', 'lifetime_end_ts'], unique=True) + ### end Alembic commands ### + + +def downgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.drop_index('repositorytag_repository_id_name_lifetime_end_ts', table_name='repositorytag') + ### end Alembic commands ###