summaryrefslogtreecommitdiff
path: root/migrations/versions/f5aac764ce5b_create_replies.py
blob: d8244a663f69f71f28ad19618fcc5b5ba584bc04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 ###