72 lines
2.5 KiB
Python
72 lines
2.5 KiB
Python
"""empty message
|
|
|
|
Revision ID: 33284623adec
|
|
Revises:
|
|
Create Date: 2020-07-27 11:23:41.047766
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '33284623adec'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('channel',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('channelId', sa.String(length=30), nullable=False),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('channelId')
|
|
)
|
|
op.create_table('user',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('username', sa.String(length=64), nullable=True),
|
|
sa.Column('email', sa.String(length=120), nullable=True),
|
|
sa.Column('password_hash', sa.String(length=128), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
|
|
op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
|
|
op.create_table('channel_association',
|
|
sa.Column('channel_id', sa.String(), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['channel_id'], ['channel.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], )
|
|
)
|
|
op.create_table('followers',
|
|
sa.Column('follower_id', sa.Integer(), nullable=True),
|
|
sa.Column('followed_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['followed_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['follower_id'], ['user.id'], )
|
|
)
|
|
op.create_table('post',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('body', sa.String(length=140), nullable=True),
|
|
sa.Column('timestamp', sa.String(length=100), nullable=True),
|
|
sa.Column('url', sa.String(length=100), nullable=True),
|
|
sa.Column('username', sa.String(length=24), nullable=True),
|
|
sa.Column('user_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('url')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('post')
|
|
op.drop_table('followers')
|
|
op.drop_table('channel_association')
|
|
op.drop_index(op.f('ix_user_username'), table_name='user')
|
|
op.drop_index(op.f('ix_user_email'), table_name='user')
|
|
op.drop_table('user')
|
|
op.drop_table('channel')
|
|
# ### end Alembic commands ###
|