post vote effect index

This commit is contained in:
rimu 2024-01-10 10:18:11 +13:00
parent a29a914bf0
commit 0fa8c674b2
2 changed files with 33 additions and 1 deletions

View file

@ -835,7 +835,7 @@ class PostVote(db.Model):
user_id = db.Column(db.Integer, db.ForeignKey('user.id')) user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
author_id = db.Column(db.Integer, db.ForeignKey('user.id')) author_id = db.Column(db.Integer, db.ForeignKey('user.id'))
post_id = db.Column(db.Integer, db.ForeignKey('post.id')) post_id = db.Column(db.Integer, db.ForeignKey('post.id'))
effect = db.Column(db.Float) effect = db.Column(db.Float, index=True)
created_at = db.Column(db.DateTime, default=utcnow) created_at = db.Column(db.DateTime, default=utcnow)
post = db.relationship('Post', foreign_keys=[post_id]) post = db.relationship('Post', foreign_keys=[post_id])

View file

@ -0,0 +1,32 @@
"""post vote index
Revision ID: aaf434e9e7bf
Revises: 5b4a967f9988
Create Date: 2024-01-10 10:17:47.397781
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'aaf434e9e7bf'
down_revision = '5b4a967f9988'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('post_vote', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_post_vote_effect'), ['effect'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('post_vote', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_post_vote_effect'))
# ### end Alembic commands ###