From 369452bc0549fe7caacba03809458d8daa4ab020 Mon Sep 17 00:00:00 2001 From: SvyatoslavArtymovych Date: Thu, 11 May 2023 15:07:22 +0300 Subject: [PATCH] add approved to comment and interpretation --- app/models/comment.py | 2 +- app/models/interpretation.py | 1 + .../versions/5df1fabbee7d_approved_fields.py | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/5df1fabbee7d_approved_fields.py diff --git a/app/models/comment.py b/app/models/comment.py index b46dd52..ccb7806 100644 --- a/app/models/comment.py +++ b/app/models/comment.py @@ -10,9 +10,9 @@ class Comment(BaseModel): # need to redeclare id to use it in the parent relationship id = db.Column(db.Integer, primary_key=True) text = db.Column(db.Text, unique=False, nullable=False) + approved = db.Column(db.Boolean, default=False) marked = db.Column(db.Boolean, default=False) edited = db.Column(db.Boolean, default=False) - included_with_interpretation = db.Column(db.Boolean, default=False) # Foreign keys user_id = db.Column(db.ForeignKey("users.id")) diff --git a/app/models/interpretation.py b/app/models/interpretation.py index ec73484..03d17e3 100644 --- a/app/models/interpretation.py +++ b/app/models/interpretation.py @@ -11,6 +11,7 @@ class Interpretation(BaseModel): label = db.Column(db.String(256), unique=False, nullable=False) text = db.Column(db.Text, unique=False, nullable=False) + approved = db.Column(db.Boolean, default=False) marked = db.Column(db.Boolean, default=False) created_at = db.Column(db.DateTime, default=datetime.now) diff --git a/migrations/versions/5df1fabbee7d_approved_fields.py b/migrations/versions/5df1fabbee7d_approved_fields.py new file mode 100644 index 0000000..a280f31 --- /dev/null +++ b/migrations/versions/5df1fabbee7d_approved_fields.py @@ -0,0 +1,40 @@ +"""approved fields + +Revision ID: 5df1fabbee7d +Revises: 1dfa1f2c208f +Create Date: 2023-05-11 15:06:42.883725 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '5df1fabbee7d' +down_revision = '1dfa1f2c208f' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('comments', schema=None) as batch_op: + batch_op.add_column(sa.Column('approved', sa.Boolean(), nullable=True)) + batch_op.drop_column('included_with_interpretation') + + with op.batch_alter_table('interpretations', schema=None) as batch_op: + batch_op.add_column(sa.Column('approved', sa.Boolean(), nullable=True)) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('interpretations', schema=None) as batch_op: + batch_op.drop_column('approved') + + with op.batch_alter_table('comments', schema=None) as batch_op: + batch_op.add_column(sa.Column('included_with_interpretation', sa.BOOLEAN(), autoincrement=False, nullable=True)) + batch_op.drop_column('approved') + + # ### end Alembic commands ###