Skip to content

Commit

Permalink
Add index on comment.user_id (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 authored Oct 18, 2024
1 parent 712e457 commit 4fc30b3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mwdb/model/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class Comment(db.Model):
index=True,
)
user_id = db.Column(
db.Integer, db.ForeignKey("user.id", ondelete="SET NULL"), nullable=True
db.Integer,
db.ForeignKey("user.id", ondelete="SET NULL"),
nullable=True,
index=True,
)

author = db.relationship("User", lazy="joined")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Add index on comment.user_id
Revision ID: 52bb55f76ef3
Revises: 2c44b2073670
Create Date: 2024-10-18 10:36:52.350767
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "52bb55f76ef3"
down_revision = "2c44b2073670"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f("ix_comment_user_id"), "comment", ["user_id"], unique=False)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_comment_user_id"), table_name="comment")
# ### end Alembic commands ###

0 comments on commit 4fc30b3

Please sign in to comment.