update-database
parent
87a6e92ab7
commit
d825d62cd2
Binary file not shown.
@ -1 +1 @@
|
|||||||
Generic single-database configuration.
|
Single-database configuration for Flask.
|
||||||
|
@ -1,240 +0,0 @@
|
|||||||
"""empty message
|
|
||||||
|
|
||||||
Revision ID: d3c0f90744f6
|
|
||||||
Revises:
|
|
||||||
Create Date: 2020-05-26 15:21:36.410197
|
|
||||||
|
|
||||||
"""
|
|
||||||
from alembic import op
|
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
|
||||||
revision = 'd3c0f90744f6'
|
|
||||||
down_revision = None
|
|
||||||
branch_labels = None
|
|
||||||
depends_on = None
|
|
||||||
|
|
||||||
|
|
||||||
def upgrade():
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.create_table('organizations',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('confirmed', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('name', sa.String(length=64), nullable=True),
|
|
||||||
sa.Column('teacher', sa.String(length=128), nullable=True),
|
|
||||||
sa.Column('leader_student', sa.String(length=128), nullable=True),
|
|
||||||
sa.Column('phone', sa.String(length=128), nullable=True),
|
|
||||||
sa.Column('college', sa.String(length=256), nullable=True),
|
|
||||||
sa.Column('email', sa.String(length=64), nullable=True),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
op.create_table('roles',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('name', sa.String(length=64), nullable=True),
|
|
||||||
sa.Column('default', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('permissions', sa.Integer(), nullable=True),
|
|
||||||
sa.PrimaryKeyConstraint('id'),
|
|
||||||
sa.UniqueConstraint('name')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('roles', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_roles_default'), ['default'], unique=False)
|
|
||||||
|
|
||||||
op.create_table('students',
|
|
||||||
sa.Column('student_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('id_number', sa.String(length=18), nullable=True),
|
|
||||||
sa.Column('confirmed', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('role_id', sa.Integer(), nullable=True),
|
|
||||||
sa.PrimaryKeyConstraint('student_id')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('students', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_students_role_id'), ['role_id'], unique=False)
|
|
||||||
|
|
||||||
op.create_table('users',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('ID_number', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('student_id', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('confirmed', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('email', sa.String(length=64), nullable=True),
|
|
||||||
sa.Column('username', sa.String(length=64), nullable=True),
|
|
||||||
sa.Column('password_hash', sa.String(length=128), nullable=True),
|
|
||||||
sa.Column('role_id', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('grade', sa.String(length=4), nullable=True),
|
|
||||||
sa.Column('college', sa.String(length=64), nullable=True),
|
|
||||||
sa.Column('about_me', sa.Text(), nullable=True),
|
|
||||||
sa.Column('member_since', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('last_seen', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('avatar_hash', sa.String(length=32), nullable=True),
|
|
||||||
sa.Column('avatar_img', sa.String(length=120), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('users', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_users_ID_number'), ['ID_number'], unique=True)
|
|
||||||
batch_op.create_index(batch_op.f('ix_users_email'), ['email'], unique=True)
|
|
||||||
batch_op.create_index(batch_op.f('ix_users_student_id'), ['student_id'], unique=True)
|
|
||||||
batch_op.create_index(batch_op.f('ix_users_username'), ['username'], unique=True)
|
|
||||||
|
|
||||||
op.create_table('Activity',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('activity_name', sa.String(length=256), nullable=False),
|
|
||||||
sa.Column('activity_time', sa.DateTime(), nullable=False),
|
|
||||||
sa.Column('activity_place', sa.String(length=256), nullable=False),
|
|
||||||
sa.Column('activity_describe', sa.String(length=256), nullable=False),
|
|
||||||
sa.Column('Organizer', sa.String(length=256), nullable=False),
|
|
||||||
sa.Column('is_schoolAgree', sa.Boolean(), nullable=False),
|
|
||||||
sa.Column('is_invalid', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('important', sa.INTEGER(), nullable=True),
|
|
||||||
sa.Column('announcer_id', sa.Integer(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['announcer_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('Activity', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_Activity_timestamp'), ['timestamp'], unique=False)
|
|
||||||
|
|
||||||
op.create_table('follow',
|
|
||||||
sa.Column('follower_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('followed_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['followed_id'], ['users.id'], ),
|
|
||||||
sa.ForeignKeyConstraint(['follower_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('follower_id', 'followed_id')
|
|
||||||
)
|
|
||||||
op.create_table('notification',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('username', sa.String(length=64), nullable=False),
|
|
||||||
sa.Column('action', sa.Text(), nullable=False),
|
|
||||||
sa.Column('object', sa.String(length=64), nullable=False),
|
|
||||||
sa.Column('object_id', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('is_read', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('receiver_id', sa.Integer(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['receiver_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('notification', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_notification_timestamp'), ['timestamp'], unique=False)
|
|
||||||
|
|
||||||
op.create_table('posts',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('title', sa.Text(), nullable=True),
|
|
||||||
sa.Column('body', sa.Text(), nullable=True),
|
|
||||||
sa.Column('body_html', sa.Text(), nullable=True),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('author_id', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('important', sa.INTEGER(), nullable=True),
|
|
||||||
sa.Column('recent_activity', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('is_anonymous', sa.Boolean(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('posts', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_posts_recent_activity'), ['recent_activity'], unique=False)
|
|
||||||
batch_op.create_index(batch_op.f('ix_posts_timestamp'), ['timestamp'], unique=False)
|
|
||||||
|
|
||||||
op.create_table('transaction',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('item_name', sa.String(length=64), nullable=False),
|
|
||||||
sa.Column('item_describe', sa.Text(), nullable=False),
|
|
||||||
sa.Column('link', sa.Text(), nullable=False),
|
|
||||||
sa.Column('transaction_mode', sa.String(length=64), nullable=False),
|
|
||||||
sa.Column('is_sold', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('seller_WeChat', sa.Text(), nullable=False),
|
|
||||||
sa.Column('seller_id', sa.Integer(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['seller_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('transaction', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_transaction_timestamp'), ['timestamp'], unique=False)
|
|
||||||
|
|
||||||
op.create_table('collect',
|
|
||||||
sa.Column('collecter_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('collected_transaction_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['collected_transaction_id'], ['transaction.id'], ),
|
|
||||||
sa.ForeignKeyConstraint(['collecter_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('collecter_id', 'collected_transaction_id')
|
|
||||||
)
|
|
||||||
op.create_table('comments',
|
|
||||||
sa.Column('id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('body', sa.Text(), nullable=True),
|
|
||||||
sa.Column('body_html', sa.Text(), nullable=True),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.Column('disabled', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('author_id', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('post_id', sa.Integer(), nullable=True),
|
|
||||||
sa.Column('is_anonymous', sa.Boolean(), nullable=True),
|
|
||||||
sa.Column('replied_id', sa.Integer(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['author_id'], ['users.id'], ),
|
|
||||||
sa.ForeignKeyConstraint(['post_id'], ['posts.id'], ),
|
|
||||||
sa.ForeignKeyConstraint(['replied_id'], ['comments.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('id')
|
|
||||||
)
|
|
||||||
with op.batch_alter_table('comments', schema=None) as batch_op:
|
|
||||||
batch_op.create_index(batch_op.f('ix_comments_timestamp'), ['timestamp'], unique=False)
|
|
||||||
|
|
||||||
op.create_table('likes',
|
|
||||||
sa.Column('liker_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('liked_post_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['liked_post_id'], ['posts.id'], ),
|
|
||||||
sa.ForeignKeyConstraint(['liker_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('liker_id', 'liked_post_id')
|
|
||||||
)
|
|
||||||
op.create_table('want',
|
|
||||||
sa.Column('wanter_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('wanted_Activity_id', sa.Integer(), nullable=False),
|
|
||||||
sa.Column('timestamp', sa.DateTime(), nullable=True),
|
|
||||||
sa.ForeignKeyConstraint(['wanted_Activity_id'], ['Activity.id'], ),
|
|
||||||
sa.ForeignKeyConstraint(['wanter_id'], ['users.id'], ),
|
|
||||||
sa.PrimaryKeyConstraint('wanter_id', 'wanted_Activity_id')
|
|
||||||
)
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade():
|
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
|
||||||
op.drop_table('want')
|
|
||||||
op.drop_table('likes')
|
|
||||||
with op.batch_alter_table('comments', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_comments_timestamp'))
|
|
||||||
|
|
||||||
op.drop_table('comments')
|
|
||||||
op.drop_table('collect')
|
|
||||||
with op.batch_alter_table('transaction', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_transaction_timestamp'))
|
|
||||||
|
|
||||||
op.drop_table('transaction')
|
|
||||||
with op.batch_alter_table('posts', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_posts_timestamp'))
|
|
||||||
batch_op.drop_index(batch_op.f('ix_posts_recent_activity'))
|
|
||||||
|
|
||||||
op.drop_table('posts')
|
|
||||||
with op.batch_alter_table('notification', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_notification_timestamp'))
|
|
||||||
|
|
||||||
op.drop_table('notification')
|
|
||||||
op.drop_table('follow')
|
|
||||||
with op.batch_alter_table('Activity', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_Activity_timestamp'))
|
|
||||||
|
|
||||||
op.drop_table('Activity')
|
|
||||||
with op.batch_alter_table('users', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_users_username'))
|
|
||||||
batch_op.drop_index(batch_op.f('ix_users_student_id'))
|
|
||||||
batch_op.drop_index(batch_op.f('ix_users_email'))
|
|
||||||
batch_op.drop_index(batch_op.f('ix_users_ID_number'))
|
|
||||||
|
|
||||||
op.drop_table('users')
|
|
||||||
with op.batch_alter_table('students', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_students_role_id'))
|
|
||||||
|
|
||||||
op.drop_table('students')
|
|
||||||
with op.batch_alter_table('roles', schema=None) as batch_op:
|
|
||||||
batch_op.drop_index(batch_op.f('ix_roles_default'))
|
|
||||||
|
|
||||||
op.drop_table('roles')
|
|
||||||
op.drop_table('organizations')
|
|
||||||
# ### end Alembic commands ###
|
|
Loading…
Reference in New Issue