127be3fb000_added_m2m_forumgroups_table.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. """Added m2m forumgroups table
  2. Revision ID: 127be3fb000
  3. Revises: 514ca0a3282c
  4. Create Date: 2015-04-08 22:25:52.809557
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '127be3fb000'
  8. down_revision = '514ca0a3282c'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. ### commands auto generated by Alembic - please adjust! ###
  13. op.create_table('forumgroups',
  14. sa.Column('group_id', sa.Integer(), nullable=False),
  15. sa.Column('forum_id', sa.Integer(), nullable=False),
  16. sa.ForeignKeyConstraint(['forum_id'], ['forums.id'], name='fk_forum_id', use_alter=True),
  17. sa.ForeignKeyConstraint(['group_id'], ['groups.id'], )
  18. )
  19. op.create_foreign_key('fk_fr_forum_id', 'forumsread', 'forums', ['forum_id'], ['id'])
  20. op.create_foreign_key('fk_forum_id', 'moderators', 'forums', ['forum_id'], ['id'])
  21. op.create_foreign_key('fk_post_topic_id', 'posts', 'topics', ['topic_id'], ['id'])
  22. op.create_foreign_key('fk_settingsgroup', 'settings', 'settingsgroup', ['settingsgroup'], ['key'])
  23. op.create_foreign_key('fk_topic_forum_id', 'topics', 'forums', ['forum_id'], ['id'])
  24. op.create_foreign_key('fk_tr_topic_id', 'topicsread', 'topics', ['topic_id'], ['id'])
  25. op.create_foreign_key('fk_tr_forum_id', 'topicsread', 'forums', ['forum_id'], ['id'])
  26. op.create_foreign_key('fk_tracker_topic_id', 'topictracker', 'topics', ['topic_id'], ['id'])
  27. ### end Alembic commands ###
  28. def downgrade():
  29. ### commands auto generated by Alembic - please adjust! ###
  30. op.drop_constraint('fk_tracker_topic_id', 'topictracker', type_='foreignkey')
  31. op.drop_constraint('fk_tr_forum_id', 'topicsread', type_='foreignkey')
  32. op.drop_constraint('fk_tr_topic_id', 'topicsread', type_='foreignkey')
  33. op.drop_constraint('fk_topic_forum_id', 'topics', type_='foreignkey')
  34. op.drop_constraint('fk_settingsgroup', 'settings', type_='foreignkey')
  35. op.drop_constraint('fk_post_topic_id', 'posts', type_='foreignkey')
  36. op.drop_constraint('fk_forum_id', 'moderators', type_='foreignkey')
  37. op.drop_constraint('fk_fr_forum_id', 'forumsread', type_='foreignkey')
  38. op.drop_table('forumgroups')
  39. ### end Alembic commands ###