Set up database changes for comment filtering
This commit is contained in:
parent
b9ab682d18
commit
d530cc6a7c
3 changed files with 34 additions and 2 deletions
|
@ -48,6 +48,7 @@ class Comment(Base):
|
|||
blackjack_result = Column(String)
|
||||
wordle_result = Column(String)
|
||||
treasure_amount = Column(String)
|
||||
filter_state = Column(String, nullable=False)
|
||||
|
||||
Index('comment_parent_index', parent_comment_id)
|
||||
Index('comment_post_id_index', parent_submission)
|
||||
|
|
|
@ -45,8 +45,9 @@ class CommentFlag(Base):
|
|||
|
||||
__tablename__ = "commentflags"
|
||||
|
||||
comment_id = Column(Integer, ForeignKey("comments.id"), primary_key=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=True)
|
||||
id = Column(Integer, primary_key=True)
|
||||
comment_id = Column(Integer, ForeignKey("comments.id"), primary_key=False)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), primary_key=False)
|
||||
reason = Column(String)
|
||||
created_utc = Column(Integer, nullable=False)
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
"""Add filter_state to comments
|
||||
|
||||
Revision ID: c5bbdae9a233
|
||||
Revises: dd9a3c418274
|
||||
Create Date: 2022-06-07 03:30:19.727632+00:00
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c5bbdae9a233'
|
||||
down_revision = 'dd9a3c418274'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('comments', sa.Column('filter_state', sa.String(40), nullable=True))
|
||||
op.execute("UPDATE comments SET filter_state = 'normal';")
|
||||
op.alter_column('comments', 'filter_state', nullable=False)
|
||||
op.drop_constraint('commentflags_pkey', 'commentflags')
|
||||
op.add_column('commentflags', sa.Column('id', sa.Integer, nullable=False, primary_key=True, autoincrement=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('comments', 'filter_state')
|
||||
op.drop_column('commentflags', 'id')
|
||||
op.create_primary_key('commentflags_pkey', 'commentflags', ['post_id', 'user_id'])
|
Loading…
Add table
Add a link
Reference in a new issue