From 4ad592e7ce837a023e38d1c1d9f8636bfd59b3b6 Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Mon, 6 Oct 2014 18:44:37 -0400 Subject: [PATCH] Add an index to the image storage uuid to improve performance. --- data/database.py | 2 +- ..._add_an_index_to_the_uuid_in_the_image_.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 data/migrations/versions/b1d41e2071b_add_an_index_to_the_uuid_in_the_image_.py diff --git a/data/database.py b/data/database.py index aba62b88b..f7c4b8931 100644 --- a/data/database.py +++ b/data/database.py @@ -257,7 +257,7 @@ class EmailConfirmation(BaseModel): class ImageStorage(BaseModel): - uuid = CharField(default=uuid_generator) + uuid = CharField(default=uuid_generator, index=True) checksum = CharField(null=True) created = DateTimeField(null=True) comment = TextField(null=True) diff --git a/data/migrations/versions/b1d41e2071b_add_an_index_to_the_uuid_in_the_image_.py b/data/migrations/versions/b1d41e2071b_add_an_index_to_the_uuid_in_the_image_.py new file mode 100644 index 000000000..71a9df794 --- /dev/null +++ b/data/migrations/versions/b1d41e2071b_add_an_index_to_the_uuid_in_the_image_.py @@ -0,0 +1,22 @@ +"""Add an index to the uuid in the image storage table. + +Revision ID: b1d41e2071b +Revises: 9a1087b007d +Create Date: 2014-10-06 18:42:10.021235 + +""" + +# revision identifiers, used by Alembic. +revision = 'b1d41e2071b' +down_revision = '9a1087b007d' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(tables): + op.create_index('imagestorage_uuid', 'imagestorage', ['uuid'], unique=True) + + +def downgrade(tables): + op.drop_index('imagestorage_uuid', table_name='imagestorage')