|
| 1 | +"""squash |
| 2 | +
|
| 3 | +Revision ID: 1051 |
| 4 | +Revises: |
| 5 | +Create Date: 2017-12-13 13:17:31.742850 |
| 6 | +""" |
| 7 | + |
| 8 | +from alembic import op |
| 9 | +import sqlalchemy as sa |
| 10 | + |
| 11 | + |
| 12 | +revision = '1051' |
| 13 | +down_revision = None |
| 14 | +branch_labels = ('default',) |
| 15 | +depends_on = None |
| 16 | + |
| 17 | + |
| 18 | +def upgrade(): |
| 19 | + op.create_table('group', |
| 20 | + sa.Column('id', sa.Integer(), nullable=False), |
| 21 | + sa.Column('name', sa.String(), nullable=False), |
| 22 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_group')), |
| 23 | + sa.UniqueConstraint('name', name=op.f('uq_group_name')) |
| 24 | + ) |
| 25 | + op.create_table('se_question', |
| 26 | + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), |
| 27 | + sa.Column('title', sa.String(), nullable=False), |
| 28 | + sa.Column('body', sa.String(), nullable=False), |
| 29 | + sa.Column('link', sa.String(), nullable=False), |
| 30 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_se_question')) |
| 31 | + ) |
| 32 | + op.create_table('se_user', |
| 33 | + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), |
| 34 | + sa.Column('display_name', sa.String(), nullable=False), |
| 35 | + sa.Column('profile_image', sa.String(), nullable=False), |
| 36 | + sa.Column('profile_link', sa.String(), nullable=False), |
| 37 | + sa.Column('reputation', sa.Integer(), nullable=False), |
| 38 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_se_user')) |
| 39 | + ) |
| 40 | + op.create_table('tag', |
| 41 | + sa.Column('id', sa.Integer(), nullable=False), |
| 42 | + sa.Column('name', sa.String(), nullable=False), |
| 43 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_tag')), |
| 44 | + sa.UniqueConstraint('name', name=op.f('uq_tag_name')) |
| 45 | + ) |
| 46 | + op.create_table('transcript', |
| 47 | + sa.Column('id', sa.Integer(), nullable=False), |
| 48 | + sa.Column('title', sa.String(), nullable=False), |
| 49 | + sa.Column('ts', sa.DateTime(), nullable=False), |
| 50 | + sa.Column('body', sa.String(), nullable=False), |
| 51 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_transcript')) |
| 52 | + ) |
| 53 | + op.create_table('chat_message', |
| 54 | + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), |
| 55 | + sa.Column('room_id', sa.Integer(), nullable=False), |
| 56 | + sa.Column('user_id', sa.Integer(), nullable=False), |
| 57 | + sa.Column('ts', sa.DateTime(), nullable=False), |
| 58 | + sa.Column('content', sa.String(), nullable=False), |
| 59 | + sa.Column('rendered', sa.Boolean(), nullable=False), |
| 60 | + sa.Column('stars', sa.Integer(), nullable=False), |
| 61 | + sa.ForeignKeyConstraint(['user_id'], ['se_user.id'], name=op.f('fk_chat_message_user_id_se_user')), |
| 62 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_chat_message')) |
| 63 | + ) |
| 64 | + op.create_table('group_group', |
| 65 | + sa.Column('member_id', sa.Integer(), nullable=False), |
| 66 | + sa.Column('group_id', sa.Integer(), nullable=False), |
| 67 | + sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_group_group_group_id_group')), |
| 68 | + sa.ForeignKeyConstraint(['member_id'], ['group.id'], name=op.f('fk_group_group_member_id_group')), |
| 69 | + sa.PrimaryKeyConstraint('member_id', 'group_id', name=op.f('pk_group_group')) |
| 70 | + ) |
| 71 | + op.create_table('se_question_tag', |
| 72 | + sa.Column('se_question_id', sa.Integer(), nullable=False), |
| 73 | + sa.Column('tag_id', sa.Integer(), nullable=False), |
| 74 | + sa.ForeignKeyConstraint(['se_question_id'], ['se_question.id'], name=op.f('fk_se_question_tag_se_question_id_se_question')), |
| 75 | + sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], name=op.f('fk_se_question_tag_tag_id_tag')), |
| 76 | + sa.PrimaryKeyConstraint('se_question_id', 'tag_id', name=op.f('pk_se_question_tag')) |
| 77 | + ) |
| 78 | + op.create_table('user', |
| 79 | + sa.Column('id', sa.Integer(), nullable=False), |
| 80 | + sa.Column('superuser', sa.Boolean(), nullable=False), |
| 81 | + sa.ForeignKeyConstraint(['id'], ['se_user.id'], name=op.f('fk_user_id_se_user')), |
| 82 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_user')) |
| 83 | + ) |
| 84 | + op.create_table('canon_item', |
| 85 | + sa.Column('id', sa.Integer(), nullable=False), |
| 86 | + sa.Column('title', sa.String(), nullable=False), |
| 87 | + sa.Column('excerpt', sa.String(), nullable=False), |
| 88 | + sa.Column('body', sa.String(), nullable=False), |
| 89 | + sa.Column('draft', sa.Boolean(), nullable=False), |
| 90 | + sa.Column('community', sa.Boolean(), nullable=False), |
| 91 | + sa.Column('updated_by_id', sa.Integer(), nullable=False), |
| 92 | + sa.ForeignKeyConstraint(['updated_by_id'], ['user.id'], name=op.f('fk_canon_item_updated_by_id_user')), |
| 93 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_canon_item')) |
| 94 | + ) |
| 95 | + op.create_table('salad', |
| 96 | + sa.Column('id', sa.Integer(), nullable=False), |
| 97 | + sa.Column('term', sa.String(), nullable=False), |
| 98 | + sa.Column('definition', sa.String(), nullable=False), |
| 99 | + sa.Column('position', sa.Integer(), nullable=False), |
| 100 | + sa.Column('updated_by_id', sa.Integer(), nullable=False), |
| 101 | + sa.ForeignKeyConstraint(['updated_by_id'], ['user.id'], name=op.f('fk_salad_updated_by_id_user')), |
| 102 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_salad')), |
| 103 | + sa.UniqueConstraint('term', name=op.f('uq_salad_term')) |
| 104 | + ) |
| 105 | + op.create_table('transcript_message', |
| 106 | + sa.Column('transcript_id', sa.Integer(), nullable=False), |
| 107 | + sa.Column('message_id', sa.Integer(), nullable=False), |
| 108 | + sa.ForeignKeyConstraint(['message_id'], ['chat_message.id'], name=op.f('fk_transcript_message_message_id_chat_message')), |
| 109 | + sa.ForeignKeyConstraint(['transcript_id'], ['transcript.id'], name=op.f('fk_transcript_message_transcript_id_transcript')), |
| 110 | + sa.PrimaryKeyConstraint('transcript_id', 'message_id', name=op.f('pk_transcript_message')) |
| 111 | + ) |
| 112 | + op.create_table('user_group', |
| 113 | + sa.Column('user_id', sa.Integer(), nullable=False), |
| 114 | + sa.Column('group_id', sa.Integer(), nullable=False), |
| 115 | + sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_user_group_group_id_group')), |
| 116 | + sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_user_group_user_id_user')), |
| 117 | + sa.PrimaryKeyConstraint('user_id', 'group_id', name=op.f('pk_user_group')) |
| 118 | + ) |
| 119 | + op.create_table('wiki_page', |
| 120 | + sa.Column('id', sa.Integer(), nullable=False), |
| 121 | + sa.Column('title', sa.String(), nullable=False), |
| 122 | + sa.Column('body', sa.String(), nullable=False), |
| 123 | + sa.Column('updated', sa.DateTime(), nullable=False), |
| 124 | + sa.Column('draft', sa.Boolean(), nullable=False), |
| 125 | + sa.Column('community', sa.Boolean(), nullable=False), |
| 126 | + sa.Column('author_id', sa.Integer(), nullable=False), |
| 127 | + sa.Column('redirect_id', sa.Integer(), nullable=True), |
| 128 | + sa.ForeignKeyConstraint(['author_id'], ['user.id'], name=op.f('fk_wiki_page_author_id_user')), |
| 129 | + sa.ForeignKeyConstraint(['redirect_id'], ['wiki_page.id'], name=op.f('fk_wiki_page_redirect_id_wiki_page')), |
| 130 | + sa.PrimaryKeyConstraint('id', name=op.f('pk_wiki_page')), |
| 131 | + sa.UniqueConstraint('title', name=op.f('uq_wiki_page_title')) |
| 132 | + ) |
| 133 | + op.create_table('canon_item_se_question', |
| 134 | + sa.Column('canon_item_id', sa.Integer(), nullable=False), |
| 135 | + sa.Column('se_question_id', sa.Integer(), nullable=False), |
| 136 | + sa.ForeignKeyConstraint(['canon_item_id'], ['canon_item.id'], name=op.f('fk_canon_item_se_question_canon_item_id_canon_item')), |
| 137 | + sa.ForeignKeyConstraint(['se_question_id'], ['se_question.id'], name=op.f('fk_canon_item_se_question_se_question_id_se_question')), |
| 138 | + sa.PrimaryKeyConstraint('canon_item_id', 'se_question_id', name=op.f('pk_canon_item_se_question')) |
| 139 | + ) |
| 140 | + op.create_table('canon_item_tag', |
| 141 | + sa.Column('canon_item_id', sa.Integer(), nullable=False), |
| 142 | + sa.Column('tag_id', sa.Integer(), nullable=False), |
| 143 | + sa.ForeignKeyConstraint(['canon_item_id'], ['canon_item.id'], name=op.f('fk_canon_item_tag_canon_item_id_canon_item')), |
| 144 | + sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], name=op.f('fk_canon_item_tag_tag_id_tag')), |
| 145 | + sa.PrimaryKeyConstraint('canon_item_id', 'tag_id', name=op.f('pk_canon_item_tag')) |
| 146 | + ) |
| 147 | + |
| 148 | + |
| 149 | +def downgrade(): |
| 150 | + op.drop_table('canon_item_tag') |
| 151 | + op.drop_table('canon_item_se_question') |
| 152 | + op.drop_table('wiki_page') |
| 153 | + op.drop_table('user_group') |
| 154 | + op.drop_table('transcript_message') |
| 155 | + op.drop_table('salad') |
| 156 | + op.drop_table('canon_item') |
| 157 | + op.drop_table('user') |
| 158 | + op.drop_table('se_question_tag') |
| 159 | + op.drop_table('group_group') |
| 160 | + op.drop_table('chat_message') |
| 161 | + op.drop_table('transcript') |
| 162 | + op.drop_table('tag') |
| 163 | + op.drop_table('se_user') |
| 164 | + op.drop_table('se_question') |
| 165 | + op.drop_table('group') |
0 commit comments