server/db: add missing migrations

This commit is contained in:
rr- 2016-04-19 12:08:59 +02:00
parent 2fba374e65
commit 59473799a4
3 changed files with 93 additions and 1 deletions

View File

@ -1,5 +1,5 @@
''' '''
Create tags tables Create tag tables
Revision ID: 00cb3a2734db Revision ID: 00cb3a2734db
Created at: 2016-04-15 23:15:36.255429 Created at: 2016-04-15 23:15:36.255429

View File

@ -0,0 +1,62 @@
'''
Create post tables
Revision ID: 336a76ec1338
Created at: 2016-04-19 12:06:08.649503
'''
import sqlalchemy as sa
from alembic import op
revision = '336a76ec1338'
down_revision = '00cb3a2734db'
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'post',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('creation_time', sa.DateTime(), nullable=False),
sa.Column('last_edit_time', sa.DateTime(), nullable=True),
sa.Column('safety', sa.String(length=32), nullable=False),
sa.Column('type', sa.String(length=32), nullable=False),
sa.Column('checksum', sa.String(length=64), nullable=False),
sa.Column('source', sa.String(length=200), nullable=True),
sa.Column('file_size', sa.Integer(), nullable=True),
sa.Column('image_width', sa.Integer(), nullable=True),
sa.Column('image_height', sa.Integer(), nullable=True),
sa.Column('flags', sa.Integer(), nullable=False),
sa.Column('auto_fav_count', sa.Integer(), nullable=False),
sa.Column('auto_score', sa.Integer(), nullable=False),
sa.Column('auto_feature_count', sa.Integer(), nullable=False),
sa.Column('auto_comment_count', sa.Integer(), nullable=False),
sa.Column('auto_note_count', sa.Integer(), nullable=False),
sa.Column('auto_fav_time', sa.Integer(), nullable=False),
sa.Column('auto_feature_time', sa.Integer(), nullable=False),
sa.Column('auto_comment_creation_time', sa.Integer(), nullable=False),
sa.Column('auto_comment_edit_time', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['user.id']),
sa.PrimaryKeyConstraint('id'))
op.create_table(
'post_relation',
sa.Column('parent_id', sa.Integer(), nullable=False),
sa.Column('child_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['child_id'], ['post.id']),
sa.ForeignKeyConstraint(['parent_id'], ['post.id']),
sa.PrimaryKeyConstraint('parent_id', 'child_id'))
op.create_table(
'post_tag',
sa.Column('post_id', sa.Integer(), nullable=False),
sa.Column('tag_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['post_id'], ['post.id']),
sa.ForeignKeyConstraint(['tag_id'], ['tag.id']),
sa.PrimaryKeyConstraint('post_id', 'tag_id'))
def downgrade():
op.drop_table('post_tag')
op.drop_table('post_relation')
op.drop_table('post')

View File

@ -0,0 +1,30 @@
'''
Create snapshot table
Revision ID: 565e01e3cf6d
Created at: 2016-04-19 12:07:58.372426
'''
import sqlalchemy as sa
from alembic import op
revision = '565e01e3cf6d'
down_revision = '336a76ec1338'
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'snapshot',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('creation_time', sa.DateTime(), nullable=False),
sa.Column('resource_type', sa.String(length=32), nullable=False),
sa.Column('resource_id', sa.Integer(), nullable=False),
sa.Column('operation', sa.String(length=16), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('data', sa.PickleType(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id']),
sa.PrimaryKeyConstraint('id'))
def downgrade():
op.drop_table('snapshot')