diff --git a/app/models.py b/app/models.py index 1f600c5a..ae274b6d 100644 --- a/app/models.py +++ b/app/models.py @@ -711,7 +711,7 @@ class PostReply(db.Model): community_id = db.Column(db.Integer, db.ForeignKey('community.id'), index=True) domain_id = db.Column(db.Integer, db.ForeignKey('domain.id'), index=True) image_id = db.Column(db.Integer, db.ForeignKey('file.id'), index=True) - parent_id = db.Column(db.Integer) + parent_id = db.Column(db.Integer, index=True) root_id = db.Column(db.Integer) depth = db.Column(db.Integer, default=0) instance_id = db.Column(db.Integer, db.ForeignKey('instance.id'), index=True) diff --git a/migrations/versions/d37fe77e043c_index_parent_id.py b/migrations/versions/d37fe77e043c_index_parent_id.py new file mode 100644 index 00000000..8f0cf62b --- /dev/null +++ b/migrations/versions/d37fe77e043c_index_parent_id.py @@ -0,0 +1,32 @@ +"""index parent_id + +Revision ID: d37fe77e043c +Revises: f19d761c216d +Create Date: 2024-02-09 15:14:13.274755 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'd37fe77e043c' +down_revision = 'f19d761c216d' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('post_reply', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_post_reply_parent_id'), ['parent_id'], unique=False) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('post_reply', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_post_reply_parent_id')) + + # ### end Alembic commands ###