/
9270baf773a5_add_comments_to_site_updates.py
42 lines (35 loc) · 1.83 KB
/
9270baf773a5_add_comments_to_site_updates.py
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
"""Add comments to site updates
Revision ID: 9270baf773a5
Revises: 7f0e262d6370
Create Date: 2019-01-21 16:41:17.360120
"""
# revision identifiers, used by Alembic.
revision = '9270baf773a5'
down_revision = '7f0e262d6370'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('siteupdatecomment',
sa.Column('commentid', sa.Integer(), nullable=False),
sa.Column('userid', sa.Integer(), nullable=False),
sa.Column('targetid', sa.Integer(), nullable=False),
sa.Column('parentid', sa.Integer(), nullable=True),
sa.Column('content', sa.String(length=10000), nullable=False),
sa.Column('created_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text(u'now()'), nullable=False),
sa.Column('hidden_at', postgresql.TIMESTAMP(timezone=True), nullable=True),
sa.Column('hidden_by', sa.Integer(), nullable=True),
sa.CheckConstraint(u'hidden_by IS NULL OR hidden_at IS NOT NULL', name='siteupdatecomment_hidden_check'),
sa.ForeignKeyConstraint(['hidden_by'], ['login.userid'], name='siteupdatecomment_hidden_by_fkey', ondelete='SET NULL'),
sa.ForeignKeyConstraint(['targetid', 'parentid'], ['siteupdatecomment.targetid', 'siteupdatecomment.commentid'], name='siteupdatecomment_parentid_fkey'),
sa.ForeignKeyConstraint(['targetid'], ['siteupdate.updateid'], name='siteupdatecomment_targetid_fkey'),
sa.ForeignKeyConstraint(['userid'], ['login.userid'], name='siteupdatecomment_userid_fkey'),
sa.PrimaryKeyConstraint('commentid'),
sa.UniqueConstraint('targetid', 'commentid')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('siteupdatecomment')
# ### end Alembic commands ###