mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
add index #348
This commit is contained in:
parent
3e0c94c77c
commit
d5ae01b456
2 changed files with 52 additions and 2 deletions
|
@ -2058,7 +2058,7 @@ class UserRegistration(db.Model):
|
|||
class PostVote(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True)
|
||||
author_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
||||
author_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True)
|
||||
post_id = db.Column(db.Integer, db.ForeignKey('post.id'), index=True)
|
||||
effect = db.Column(db.Float, index=True)
|
||||
created_at = db.Column(db.DateTime, default=utcnow)
|
||||
|
@ -2068,7 +2068,7 @@ class PostVote(db.Model):
|
|||
class PostReplyVote(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) # who voted
|
||||
author_id = db.Column(db.Integer, db.ForeignKey('user.id')) # the author of the reply voted on - who's reputation is affected
|
||||
author_id = db.Column(db.Integer, db.ForeignKey('user.id'), index=True) # the author of the reply voted on - who's reputation is affected
|
||||
post_reply_id = db.Column(db.Integer, db.ForeignKey('post_reply.id'), index=True)
|
||||
effect = db.Column(db.Float)
|
||||
created_at = db.Column(db.DateTime, default=utcnow)
|
||||
|
|
50
migrations/versions/d32ef1893ce4_index_on_vote_author_id.py
Normal file
50
migrations/versions/d32ef1893ce4_index_on_vote_author_id.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
"""index on vote.author_id
|
||||
|
||||
Revision ID: d32ef1893ce4
|
||||
Revises: 26138ecda7c3
|
||||
Create Date: 2024-11-15 16:40:21.080337
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd32ef1893ce4'
|
||||
down_revision = '26138ecda7c3'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('post_reply_vote', schema=None) as batch_op:
|
||||
try:
|
||||
batch_op.create_index(batch_op.f('ix_post_reply_vote_author_id'), ['author_id'], unique=False)
|
||||
except:
|
||||
...
|
||||
|
||||
with op.batch_alter_table('post_vote', schema=None) as batch_op:
|
||||
try:
|
||||
batch_op.create_index(batch_op.f('ix_post_vote_author_id'), ['author_id'], unique=False)
|
||||
except:
|
||||
...
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('post_vote', schema=None) as batch_op:
|
||||
try:
|
||||
batch_op.drop_index(batch_op.f('ix_post_vote_author_id'))
|
||||
except:
|
||||
...
|
||||
|
||||
with op.batch_alter_table('post_reply_vote', schema=None) as batch_op:
|
||||
try:
|
||||
batch_op.drop_index(batch_op.f('ix_post_reply_vote_author_id'))
|
||||
except:
|
||||
...
|
||||
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in a new issue