db: drop redundant user_id index on email_sends

The composite ix_email_sends_user_kind_sent (user_id, kind, sent_at)
already satisfies leftmost-prefix WHERE user_id=? lookups on both
MariaDB and SQLite, so the standalone per-column index was dead
weight. Drop it before the migration ever lands in prod.
This commit is contained in:
Giorgio Gilestro 2026-05-25 22:55:33 +02:00
parent 454df3ee0f
commit 51efccd3b1
2 changed files with 1 additions and 5 deletions

View file

@ -46,13 +46,9 @@ def upgrade() -> None:
"email_sends", "email_sends",
["user_id", "kind", "sent_at"], ["user_id", "kind", "sent_at"],
) )
op.create_index(
op.f("ix_email_sends_user_id"), "email_sends", ["user_id"],
)
def downgrade() -> None: def downgrade() -> None:
op.drop_index(op.f("ix_email_sends_user_id"), table_name="email_sends")
op.drop_index("ix_email_sends_user_kind_sent", table_name="email_sends") op.drop_index("ix_email_sends_user_kind_sent", table_name="email_sends")
op.drop_table("email_sends") op.drop_table("email_sends")
op.drop_column("users", "digest_tone") op.drop_column("users", "digest_tone")

View file

@ -328,7 +328,7 @@ class EmailSend(Base):
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True) id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
user_id: Mapped[int] = mapped_column( user_id: Mapped[int] = mapped_column(
ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True, ForeignKey("users.id", ondelete="CASCADE"), nullable=False,
) )
kind: Mapped[str] = mapped_column(String(16), nullable=False) # "daily" | "weekly" kind: Mapped[str] = mapped_column(String(16), nullable=False) # "daily" | "weekly"
sent_at: Mapped[datetime] = mapped_column( sent_at: Mapped[datetime] = mapped_column(