"""empty message

Revision ID: 0e10d8a3a510
Revises: <PASSWORD>
Create Date: 2020-02-08 14:32:53.448981

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '0e10d8a3a510'
down_revision = '<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_group',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('group_name', sa.String(length=80), nullable=True),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('group_name')
    )
    op.create_table('user_chat_log',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('from_user', sa.Integer(), nullable=True),
    sa.Column('to_user', sa.Integer(), nullable=True),
    sa.Column('message', sa.String(length=128), nullable=True),
    sa.Column('has_read', sa.Boolean(), nullable=True),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['from_user'], ['user.id'], ),
    sa.ForeignKeyConstraint(['to_user'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user_group_chat_log',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('from_group', sa.Integer(), nullable=True),
    sa.Column('to_user', sa.Integer(), nullable=True),
    sa.Column('message', sa.String(length=128), nullable=True),
    sa.Column('has_read', sa.Boolean(), nullable=True),
    sa.Column('create_time', sa.DateTime(), nullable=True),
    sa.Column('update_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['from_group'], ['user_group.id'], ),
    sa.ForeignKeyConstraint(['to_user'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column('user', sa.Column('friend_id', sa.Integer(), nullable=True))
    op.add_column('user', sa.Column('group_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'user', 'user', ['friend_id'], ['id'])
    op.create_foreign_key(None, 'user', 'user_group', ['group_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'user', type_='foreignkey')
    op.drop_constraint(None, 'user', type_='foreignkey')
    op.drop_column('user', 'group_id')
    op.drop_column('user', 'friend_id')
    op.drop_table('user_group_chat_log')
    op.drop_table('user_chat_log')
    op.drop_table('user_group')
    # ### end Alembic commands ###
