diff --git a/data/database.py b/data/database.py index 0d42fc009..2dc717cbe 100644 --- a/data/database.py +++ b/data/database.py @@ -576,8 +576,8 @@ class Image(BaseModel): v1_json_metadata = TextField(null=True) v1_checksum = CharField(null=True) - security_indexed = BooleanField(default=False) - security_indexed_engine = IntegerField(default=-1) + security_indexed = BooleanField(default=False, index=True) + security_indexed_engine = IntegerField(default=-1, index=True) # We use a proxy here instead of 'self' in order to disable the foreign key constraint parent = ForeignKeyField(_ImageProxy, index=True, null=True, related_name='children') diff --git a/data/migrations/versions/1b2bb93ceb82_add_indices_for_security_worker_queries.py b/data/migrations/versions/1b2bb93ceb82_add_indices_for_security_worker_queries.py new file mode 100644 index 000000000..7dd464384 --- /dev/null +++ b/data/migrations/versions/1b2bb93ceb82_add_indices_for_security_worker_queries.py @@ -0,0 +1,26 @@ +"""Add indices for security worker queries. + +Revision ID: 1b2bb93ceb82 +Revises: 22af01f81722 +Create Date: 2015-11-18 13:27:41.161898 + +""" + +# revision identifiers, used by Alembic. +revision = '1b2bb93ceb82' +down_revision = '22af01f81722' + +from alembic import op + +def upgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.create_index('image_security_indexed', 'image', ['security_indexed'], unique=False) + op.create_index('image_security_indexed_engine', 'image', ['security_indexed_engine'], unique=False) + ### end Alembic commands ### + + +def downgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.drop_index('image_security_indexed_engine', table_name='image') + op.drop_index('image_security_indexed', table_name='image') + ### end Alembic commands ###