|
@@ -1,13 +1,13 @@
|
|
|
"""init
|
|
|
|
|
|
-Revision ID: 2bafd4ae417a
|
|
|
+Revision ID: 1862dd9f586c
|
|
|
Revises: None
|
|
|
-Create Date: 2014-02-07 10:30:48.023326
|
|
|
+Create Date: 2014-02-08 14:14:13.315697
|
|
|
|
|
|
"""
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
|
-revision = '2bafd4ae417a'
|
|
|
+revision = '1862dd9f586c'
|
|
|
down_revision = None
|
|
|
|
|
|
from alembic import op
|
|
@@ -16,6 +16,13 @@ import sqlalchemy as sa
|
|
|
|
|
|
def upgrade():
|
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
|
+ op.create_table('categories',
|
|
|
+ sa.Column('id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('title', sa.String(), nullable=False),
|
|
|
+ sa.Column('description', sa.String(), nullable=True),
|
|
|
+ sa.Column('position', sa.Integer(), nullable=False),
|
|
|
+ sa.PrimaryKeyConstraint('id')
|
|
|
+ )
|
|
|
op.create_table('groups',
|
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
|
sa.Column('name', sa.String(), nullable=False),
|
|
@@ -35,13 +42,6 @@ def upgrade():
|
|
|
sa.PrimaryKeyConstraint('id'),
|
|
|
sa.UniqueConstraint('name')
|
|
|
)
|
|
|
- op.create_table('categories',
|
|
|
- sa.Column('id', sa.Integer(), nullable=False),
|
|
|
- sa.Column('title', sa.String(), nullable=False),
|
|
|
- sa.Column('description', sa.String(), nullable=True),
|
|
|
- sa.Column('position', sa.Integer(), nullable=False),
|
|
|
- sa.PrimaryKeyConstraint('id')
|
|
|
- )
|
|
|
op.create_table('users',
|
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
|
sa.Column('username', sa.String(), nullable=False),
|
|
@@ -64,33 +64,14 @@ def upgrade():
|
|
|
sa.UniqueConstraint('email'),
|
|
|
sa.UniqueConstraint('username')
|
|
|
)
|
|
|
- op.create_table('privatemessages',
|
|
|
- sa.Column('id', sa.Integer(), nullable=False),
|
|
|
+ op.create_table('forumsread',
|
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
|
- sa.Column('from_user_id', sa.Integer(), nullable=True),
|
|
|
- sa.Column('to_user_id', sa.Integer(), nullable=True),
|
|
|
- sa.Column('subject', sa.String(), nullable=True),
|
|
|
- sa.Column('message', sa.Text(), nullable=True),
|
|
|
- sa.Column('date_created', sa.DateTime(), nullable=True),
|
|
|
- sa.Column('trash', sa.Boolean(), nullable=False),
|
|
|
- sa.Column('draft', sa.Boolean(), nullable=False),
|
|
|
- sa.Column('unread', sa.Boolean(), nullable=False),
|
|
|
- sa.ForeignKeyConstraint(['from_user_id'], ['users.id'], ),
|
|
|
- sa.ForeignKeyConstraint(['to_user_id'], ['users.id'], ),
|
|
|
+ sa.Column('forum_id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('last_read', sa.DateTime(), nullable=True),
|
|
|
+ sa.Column('cleared', sa.DateTime(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['forum_id'], ['topics.id'], name='fk_forum_id', use_alter=True),
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
- sa.PrimaryKeyConstraint('id')
|
|
|
- )
|
|
|
- op.create_table('topictracker',
|
|
|
- sa.Column('user_id', sa.Integer(), nullable=False),
|
|
|
- sa.Column('topic_id', sa.Integer(), nullable=False),
|
|
|
- sa.ForeignKeyConstraint(['topic_id'], ['topics.id'], name='fk_topic_id', use_alter=True),
|
|
|
- sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
|
|
|
- )
|
|
|
- op.create_table('groups_users',
|
|
|
- sa.Column('user_id', sa.Integer(), nullable=True),
|
|
|
- sa.Column('group_id', sa.Integer(), nullable=True),
|
|
|
- sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ),
|
|
|
- sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
|
|
|
+ sa.PrimaryKeyConstraint('user_id', 'forum_id')
|
|
|
)
|
|
|
op.create_table('posts',
|
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
@@ -105,14 +86,21 @@ def upgrade():
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
sa.PrimaryKeyConstraint('id')
|
|
|
)
|
|
|
- op.create_table('forumsread',
|
|
|
+ op.create_table('privatemessages',
|
|
|
+ sa.Column('id', sa.Integer(), nullable=False),
|
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
|
- sa.Column('forum_id', sa.Integer(), nullable=False),
|
|
|
- sa.Column('last_read', sa.DateTime(), nullable=True),
|
|
|
- sa.Column('cleared', sa.DateTime(), nullable=True),
|
|
|
- sa.ForeignKeyConstraint(['forum_id'], ['topics.id'], name='fk_forum_id', use_alter=True),
|
|
|
+ sa.Column('from_user_id', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('to_user_id', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('subject', sa.String(), nullable=True),
|
|
|
+ sa.Column('message', sa.Text(), nullable=True),
|
|
|
+ sa.Column('date_created', sa.DateTime(), nullable=True),
|
|
|
+ sa.Column('trash', sa.Boolean(), nullable=False),
|
|
|
+ sa.Column('draft', sa.Boolean(), nullable=False),
|
|
|
+ sa.Column('unread', sa.Boolean(), nullable=False),
|
|
|
+ sa.ForeignKeyConstraint(['from_user_id'], ['users.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['to_user_id'], ['users.id'], ),
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
- sa.PrimaryKeyConstraint('user_id', 'forum_id')
|
|
|
+ sa.PrimaryKeyConstraint('id')
|
|
|
)
|
|
|
op.create_table('topicsread',
|
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
@@ -124,12 +112,53 @@ def upgrade():
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
sa.PrimaryKeyConstraint('user_id', 'topic_id', 'forum_id')
|
|
|
)
|
|
|
+ op.create_table('topictracker',
|
|
|
+ sa.Column('user_id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('topic_id', sa.Integer(), nullable=False),
|
|
|
+ sa.ForeignKeyConstraint(['topic_id'], ['topics.id'], name='fk_topic_id', use_alter=True),
|
|
|
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
|
|
|
+ )
|
|
|
+ op.create_table('groups_users',
|
|
|
+ sa.Column('user_id', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('group_id', sa.Integer(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
|
|
|
+ )
|
|
|
op.create_table('moderators',
|
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
|
sa.Column('forum_id', sa.Integer(), nullable=False),
|
|
|
sa.ForeignKeyConstraint(['forum_id'], ['forums.id'], name='fk_forum_id', use_alter=True),
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], )
|
|
|
)
|
|
|
+ op.create_table('reports',
|
|
|
+ sa.Column('id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('reporter_id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('reported', sa.DateTime(), nullable=True),
|
|
|
+ sa.Column('post_id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('zapped', sa.DateTime(), nullable=True),
|
|
|
+ sa.Column('zapped_by', sa.Integer(), nullable=True),
|
|
|
+ sa.Column('reason', sa.String(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['reporter_id'], ['users.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['zapped_by'], ['users.id'], ),
|
|
|
+ sa.PrimaryKeyConstraint('id')
|
|
|
+ )
|
|
|
+ op.create_table('forums',
|
|
|
+ sa.Column('id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('category_id', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('title', sa.String(), nullable=False),
|
|
|
+ sa.Column('description', sa.String(), nullable=True),
|
|
|
+ sa.Column('position', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('locked', sa.Boolean(), nullable=False),
|
|
|
+ sa.Column('show_moderators', sa.Boolean(), nullable=False),
|
|
|
+ sa.Column('external', sa.String(), nullable=True),
|
|
|
+ sa.Column('post_count', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('topic_count', sa.Integer(), nullable=False),
|
|
|
+ sa.Column('last_post_id', sa.Integer(), nullable=True),
|
|
|
+ sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ),
|
|
|
+ sa.ForeignKeyConstraint(['last_post_id'], ['posts.id'], ),
|
|
|
+ sa.PrimaryKeyConstraint('id')
|
|
|
+ )
|
|
|
op.create_table('topics',
|
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
|
sa.Column('forum_id', sa.Integer(), nullable=False),
|
|
@@ -150,36 +179,22 @@ def upgrade():
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
|
sa.PrimaryKeyConstraint('id')
|
|
|
)
|
|
|
- op.create_table('forums',
|
|
|
- sa.Column('id', sa.Integer(), nullable=False),
|
|
|
- sa.Column('category_id', sa.Integer(), nullable=False),
|
|
|
- sa.Column('title', sa.String(), nullable=False),
|
|
|
- sa.Column('description', sa.String(), nullable=True),
|
|
|
- sa.Column('position', sa.Integer(), nullable=False),
|
|
|
- sa.Column('locked', sa.Boolean(), nullable=False),
|
|
|
- sa.Column('show_moderators', sa.Boolean(), nullable=False),
|
|
|
- sa.Column('post_count', sa.Integer(), nullable=False),
|
|
|
- sa.Column('topic_count', sa.Integer(), nullable=False),
|
|
|
- sa.Column('last_post_id', sa.Integer(), nullable=True),
|
|
|
- sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ),
|
|
|
- sa.ForeignKeyConstraint(['last_post_id'], ['posts.id'], ),
|
|
|
- sa.PrimaryKeyConstraint('id')
|
|
|
- )
|
|
|
### end Alembic commands ###
|
|
|
|
|
|
|
|
|
def downgrade():
|
|
|
### commands auto generated by Alembic - please adjust! ###
|
|
|
- op.drop_table('forums')
|
|
|
op.drop_table('topics')
|
|
|
+ op.drop_table('forums')
|
|
|
+ op.drop_table('reports')
|
|
|
op.drop_table('moderators')
|
|
|
- op.drop_table('topicsread')
|
|
|
- op.drop_table('forumsread')
|
|
|
- op.drop_table('posts')
|
|
|
op.drop_table('groups_users')
|
|
|
op.drop_table('topictracker')
|
|
|
+ op.drop_table('topicsread')
|
|
|
op.drop_table('privatemessages')
|
|
|
+ op.drop_table('posts')
|
|
|
+ op.drop_table('forumsread')
|
|
|
op.drop_table('users')
|
|
|
- op.drop_table('categories')
|
|
|
op.drop_table('groups')
|
|
|
+ op.drop_table('categories')
|
|
|
### end Alembic commands ###
|