diff --git a/app/models.py b/app/models.py index 512a3050..4c05683d 100644 --- a/app/models.py +++ b/app/models.py @@ -1160,7 +1160,7 @@ class Alias(Base, ModelMixin): enabled = sa.Column(sa.Boolean(), default=True, nullable=False) custom_domain_id = sa.Column( - sa.ForeignKey("custom_domain.id", ondelete="cascade"), nullable=True + sa.ForeignKey("custom_domain.id", ondelete="cascade"), nullable=True, index=True ) custom_domain = orm.relationship("CustomDomain", foreign_keys=[custom_domain_id]) @@ -1172,7 +1172,7 @@ class Alias(Base, ModelMixin): # to know whether an alias belongs to a directory directory_id = sa.Column( - sa.ForeignKey("directory.id", ondelete="cascade"), nullable=True + sa.ForeignKey("directory.id", ondelete="cascade"), nullable=True, index=True ) note = sa.Column(sa.Text, default=None, nullable=True) diff --git a/migrations/versions/2022_022617_5047fcbd57c7_.py b/migrations/versions/2022_022617_5047fcbd57c7_.py new file mode 100644 index 00000000..0485d29d --- /dev/null +++ b/migrations/versions/2022_022617_5047fcbd57c7_.py @@ -0,0 +1,31 @@ +"""empty message + +Revision ID: 5047fcbd57c7 +Revises: 9282e982bc05 +Create Date: 2022-02-26 17:51:03.379676 + +""" +import sqlalchemy_utils +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '5047fcbd57c7' +down_revision = '9282e982bc05' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_index(op.f('ix_alias_custom_domain_id'), 'alias', ['custom_domain_id'], unique=False) + op.create_index(op.f('ix_alias_directory_id'), 'alias', ['directory_id'], unique=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f('ix_alias_directory_id'), table_name='alias') + op.drop_index(op.f('ix_alias_custom_domain_id'), table_name='alias') + # ### end Alembic commands ###