mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
more indexes
This commit is contained in:
parent
77a02dc6ed
commit
c3266823ba
2 changed files with 59 additions and 7 deletions
|
@ -340,8 +340,8 @@ class User(UserMixin, db.Model):
|
||||||
show_nsfl = db.Column(db.Boolean, default=False)
|
show_nsfl = db.Column(db.Boolean, default=False)
|
||||||
created = db.Column(db.DateTime, default=utcnow)
|
created = db.Column(db.DateTime, default=utcnow)
|
||||||
last_seen = db.Column(db.DateTime, default=utcnow, index=True)
|
last_seen = db.Column(db.DateTime, default=utcnow, index=True)
|
||||||
avatar_id = db.Column(db.Integer, db.ForeignKey('file.id'))
|
avatar_id = db.Column(db.Integer, db.ForeignKey('file.id'), index=True)
|
||||||
cover_id = db.Column(db.Integer, db.ForeignKey('file.id'))
|
cover_id = db.Column(db.Integer, db.ForeignKey('file.id'), index=True)
|
||||||
public_key = db.Column(db.Text)
|
public_key = db.Column(db.Text)
|
||||||
private_key = db.Column(db.Text)
|
private_key = db.Column(db.Text)
|
||||||
newsletter = db.Column(db.Boolean, default=True)
|
newsletter = db.Column(db.Boolean, default=True)
|
||||||
|
@ -654,19 +654,19 @@ class Post(db.Model):
|
||||||
has_embed = db.Column(db.Boolean, default=False)
|
has_embed = db.Column(db.Boolean, default=False)
|
||||||
reply_count = db.Column(db.Integer, default=0)
|
reply_count = db.Column(db.Integer, default=0)
|
||||||
score = db.Column(db.Integer, default=0, index=True) # used for 'top' ranking
|
score = db.Column(db.Integer, default=0, index=True) # used for 'top' ranking
|
||||||
nsfw = db.Column(db.Boolean, default=False)
|
nsfw = db.Column(db.Boolean, default=False, index=True)
|
||||||
nsfl = db.Column(db.Boolean, default=False)
|
nsfl = db.Column(db.Boolean, default=False, index=True)
|
||||||
sticky = db.Column(db.Boolean, default=False)
|
sticky = db.Column(db.Boolean, default=False)
|
||||||
notify_author = db.Column(db.Boolean, default=True)
|
notify_author = db.Column(db.Boolean, default=True)
|
||||||
indexable = db.Column(db.Boolean, default=False)
|
indexable = db.Column(db.Boolean, default=False)
|
||||||
from_bot = db.Column(db.Boolean, default=False)
|
from_bot = db.Column(db.Boolean, default=False, index=True)
|
||||||
created_at = db.Column(db.DateTime, index=True, default=utcnow) # this is when the content arrived here
|
created_at = db.Column(db.DateTime, index=True, default=utcnow) # this is when the content arrived here
|
||||||
posted_at = db.Column(db.DateTime, index=True, default=utcnow) # this is when the original server created it
|
posted_at = db.Column(db.DateTime, index=True, default=utcnow) # this is when the original server created it
|
||||||
last_active = db.Column(db.DateTime, index=True, default=utcnow)
|
last_active = db.Column(db.DateTime, index=True, default=utcnow)
|
||||||
ip = db.Column(db.String(50))
|
ip = db.Column(db.String(50))
|
||||||
up_votes = db.Column(db.Integer, default=0)
|
up_votes = db.Column(db.Integer, default=0)
|
||||||
down_votes = db.Column(db.Integer, default=0)
|
down_votes = db.Column(db.Integer, default=0)
|
||||||
ranking = db.Column(db.Integer, default=0) # used for 'hot' ranking
|
ranking = db.Column(db.Integer, default=0, index=True) # used for 'hot' ranking
|
||||||
language = db.Column(db.String(10))
|
language = db.Column(db.String(10))
|
||||||
edited_at = db.Column(db.DateTime)
|
edited_at = db.Column(db.DateTime)
|
||||||
reports = db.Column(db.Integer, default=0) # how many times this post has been reported. Set to -1 to ignore reports
|
reports = db.Column(db.Integer, default=0) # how many times this post has been reported. Set to -1 to ignore reports
|
||||||
|
@ -855,7 +855,7 @@ class CommunityMember(db.Model):
|
||||||
community_id = db.Column(db.Integer, db.ForeignKey('community.id'), primary_key=True)
|
community_id = db.Column(db.Integer, db.ForeignKey('community.id'), primary_key=True)
|
||||||
is_moderator = db.Column(db.Boolean, default=False)
|
is_moderator = db.Column(db.Boolean, default=False)
|
||||||
is_owner = db.Column(db.Boolean, default=False)
|
is_owner = db.Column(db.Boolean, default=False)
|
||||||
is_banned = db.Column(db.Boolean, default=False)
|
is_banned = db.Column(db.Boolean, default=False, index=True)
|
||||||
notify_new_posts = db.Column(db.Boolean, default=False)
|
notify_new_posts = db.Column(db.Boolean, default=False)
|
||||||
created_at = db.Column(db.DateTime, default=utcnow)
|
created_at = db.Column(db.DateTime, default=utcnow)
|
||||||
|
|
||||||
|
|
52
migrations/versions/a8fc7f7ba539_more_indexes.py
Normal file
52
migrations/versions/a8fc7f7ba539_more_indexes.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
"""more indexes
|
||||||
|
|
||||||
|
Revision ID: a8fc7f7ba539
|
||||||
|
Revises: 62cbf0bf515a
|
||||||
|
Create Date: 2024-02-13 17:16:47.046338
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'a8fc7f7ba539'
|
||||||
|
down_revision = '62cbf0bf515a'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('community_member', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_community_member_is_banned'), ['is_banned'], unique=False)
|
||||||
|
|
||||||
|
with op.batch_alter_table('post', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_post_from_bot'), ['from_bot'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_post_nsfl'), ['nsfl'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_post_nsfw'), ['nsfw'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_post_ranking'), ['ranking'], unique=False)
|
||||||
|
|
||||||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_user_avatar_id'), ['avatar_id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_user_cover_id'), ['cover_id'], unique=False)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_user_cover_id'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_user_avatar_id'))
|
||||||
|
|
||||||
|
with op.batch_alter_table('post', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_post_ranking'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_post_nsfw'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_post_nsfl'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_post_from_bot'))
|
||||||
|
|
||||||
|
with op.batch_alter_table('community_member', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_community_member_is_banned'))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Reference in a new issue