"""init migration

Revision ID: 1754cce34816
Revises: 
Create Date: 2020-09-29 10:35:06.174307

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1754cce34816'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('user_id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('email', sa.String(length=120), nullable=False),
    sa.Column('password', sa.Text(length=500), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=False),
    sa.Column('surname', sa.String(length=64), nullable=False),
    sa.Column('gender', sa.String(length=1), nullable=True),
    sa.Column('phone', sa.String(length=15), nullable=True),
    sa.Column('telegram_u_id', sa.Integer(), nullable=True),
    sa.Column('last_seen', sa.DateTime(), nullable=True),
    sa.Column('preferred_language', sa.String(length=4), nullable=True),
    sa.PrimaryKeyConstraint('user_id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('user_privacy',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('use_gravatar', sa.Boolean(), nullable=True),
    sa.Column('share_number', sa.Boolean(), nullable=True),
    sa.Column('share_email', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.user_id'], onupdate='CASCADE', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('user_id')
    )
    op.create_table('user_privileges',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('is_super_admin', sa.Boolean(), nullable=True),
    sa.Column('is_admin', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.user_id'], onupdate='CASCADE', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('user_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('user_privileges')
    op.drop_table('user_privacy')
    op.drop_table('user')
    # ### end Alembic commands ###
