diff options
Diffstat (limited to 'migrations/versions')
-rw-r--r-- | migrations/versions/5f6c1515e239_add_approved_to_comments.py | 32 | ||||
-rw-r--r-- | migrations/versions/f5aac764ce5b_create_replies.py | 45 |
2 files changed, 77 insertions, 0 deletions
diff --git a/migrations/versions/5f6c1515e239_add_approved_to_comments.py b/migrations/versions/5f6c1515e239_add_approved_to_comments.py new file mode 100644 index 0000000..7a0bff8 --- /dev/null +++ b/migrations/versions/5f6c1515e239_add_approved_to_comments.py @@ -0,0 +1,32 @@ +"""Add approved to comments + +Revision ID: 5f6c1515e239 +Revises: c2ca1cc5b130 +Create Date: 2024-02-05 11:13:50.341119 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '5f6c1515e239' +down_revision = 'c2ca1cc5b130' +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=False)) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('comments', schema=None) as batch_op: + batch_op.drop_column('approved') + + # ### end Alembic commands ### diff --git a/migrations/versions/f5aac764ce5b_create_replies.py b/migrations/versions/f5aac764ce5b_create_replies.py new file mode 100644 index 0000000..d8244a6 --- /dev/null +++ b/migrations/versions/f5aac764ce5b_create_replies.py @@ -0,0 +1,45 @@ +"""Create replies + +Revision ID: f5aac764ce5b +Revises: 5f6c1515e239 +Create Date: 2024-02-05 12:30:38.848776 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'f5aac764ce5b' +down_revision = '5f6c1515e239' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('replies', + sa.Column('id', sa.BigInteger(), nullable=False), + sa.Column('content', sa.Text(), nullable=False), + sa.Column('email', sa.String(length=256), nullable=True), + sa.Column('author', sa.String(length=128), nullable=True), + sa.Column('comment_id', sa.BigInteger(), nullable=False), + sa.Column('approved', sa.Boolean(), nullable=False), + sa.Column('created_at', sa.DateTime(), nullable=True), + sa.Column('updated_at', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['comment_id'], ['comments.id'], ), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('replies', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_replies_comment_id'), ['comment_id'], unique=False) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('replies', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_replies_comment_id')) + + op.drop_table('replies') + # ### end Alembic commands ### |