Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: add index on comment.object_id column #988

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mwdb/model/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ class Comment(db.Model):
timestamp = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)

object_id = db.Column(
db.Integer, db.ForeignKey("object.id", ondelete="CASCADE"), nullable=False
db.Integer,
db.ForeignKey("object.id", ondelete="CASCADE"),
nullable=False,
index=True,
)
user_id = db.Column(
db.Integer, db.ForeignKey("user.id", ondelete="SET NULL"), nullable=True
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Add index on comment.object_id

Revision ID: 2c44b2073670
Revises: 72a94f88d2b6
Create Date: 2024-10-04 15:52:04.736269

"""
import sqlalchemy as sa
from alembic import op

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


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


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