mirror of
https://github.com/simple-login/app.git
synced 2025-10-25 06:56:13 +08:00
chore: more index work (#2377)
This commit is contained in:
parent
91e614ab50
commit
ed1662a485
2 changed files with 30 additions and 1 deletions
|
|
@ -1929,10 +1929,12 @@ class Contact(Base, ModelMixin):
|
||||||
|
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
sa.UniqueConstraint("alias_id", "website_email", name="uq_contact"),
|
sa.UniqueConstraint("alias_id", "website_email", name="uq_contact"),
|
||||||
|
sa.Index("ix_contact_user_id_id", "user_id", "id"),
|
||||||
)
|
)
|
||||||
|
|
||||||
user_id = sa.Column(
|
user_id = sa.Column(
|
||||||
sa.ForeignKey(User.id, ondelete="cascade"), nullable=False, index=True
|
sa.ForeignKey(User.id, ondelete="cascade"),
|
||||||
|
nullable=False,
|
||||||
)
|
)
|
||||||
alias_id = sa.Column(
|
alias_id = sa.Column(
|
||||||
sa.ForeignKey(Alias.id, ondelete="cascade"),
|
sa.ForeignKey(Alias.id, ondelete="cascade"),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
"""contact index
|
||||||
|
|
||||||
|
Revision ID: 20e7d3ca289a
|
||||||
|
Revises: 97edba8794f8
|
||||||
|
Create Date: 2025-02-03 16:52:06.775032
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '20e7d3ca289a'
|
||||||
|
down_revision = '97edba8794f8'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
with op.get_context().autocommit_block():
|
||||||
|
op.create_index('ix_contact_user_id_id', 'contact', ['user_id', 'id'], unique=False)
|
||||||
|
op.drop_index('ix_contact_user_id', table_name='contact')
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
with op.get_context().autocommit_block():
|
||||||
|
op.create_index('ix_contact_user_id', 'contact', ['user_id'], unique=False)
|
||||||
|
op.drop_index('ix_contact_user_id_id', table_name='contact')
|
||||||
Loading…
Add table
Reference in a new issue