diff --git a/files/classes/comment.py b/files/classes/comment.py index d202cdc59..b05c30811 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -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) diff --git a/files/classes/flags.py b/files/classes/flags.py index 24b045817..994e3252b 100644 --- a/files/classes/flags.py +++ b/files/classes/flags.py @@ -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) diff --git a/migrations/versions/2022_06_07_03_30_19_c5bbdae9a233_add_filter_state_to_comments.py b/migrations/versions/2022_06_07_03_30_19_c5bbdae9a233_add_filter_state_to_comments.py new file mode 100644 index 000000000..696f05548 --- /dev/null +++ b/migrations/versions/2022_06_07_03_30_19_c5bbdae9a233_add_filter_state_to_comments.py @@ -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'])