"""First database setup, User and MyCompany

Revision ID: f6814191c813
Revises: 
Create Date: 2019-11-10 14:34:18.022383

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('my_company',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=150), nullable=True),
    sa.Column('email', sa.String(length=150), nullable=True),
    sa.Column('address', sa.String(length=150), nullable=True),
    sa.Column('postal_code', sa.Integer(), nullable=True),
    sa.Column('city', sa.String(length=64), nullable=True),
    sa.Column('province', sa.String(length=64), nullable=True),
    sa.Column('phone1', sa.String(length=64), nullable=True),
    sa.Column('phone2', sa.String(length=64), nullable=True),
    sa.Column('fax', sa.String(length=64), nullable=True),
    sa.Column('cif', sa.String(length=64), nullable=True),
    sa.Column('iva', sa.Float(), nullable=True),
    sa.Column('IBAN', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_my_company_cif'), 'my_company', ['cif'], unique=True)
    op.create_index(op.f('ix_my_company_email'), 'my_company', ['email'], unique=True)
    op.create_index(op.f('ix_my_company_fax'), 'my_company', ['fax'], unique=False)
    op.create_index(op.f('ix_my_company_name'), 'my_company', ['name'], unique=True)
    op.create_index(op.f('ix_my_company_phone1'), 'my_company', ['phone1'], unique=False)
    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.Column('about_me', sa.String(length=140), nullable=True),
    sa.Column('company_id', sa.String(length=64), nullable=True),
    sa.Column('tutorials', sa.Boolean(), nullable=True),
    sa.Column('permissions', sa.Enum('owner', 'admin', 'user', name='permissionsenum'), nullable=True),
    sa.Column('token', sa.String(length=32), nullable=True),
    sa.Column('token_expiration', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['company_id'], ['my_company.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_token'), 'user', ['token'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_token'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
    op.drop_index(op.f('ix_my_company_phone1'), table_name='my_company')
    op.drop_index(op.f('ix_my_company_name'), table_name='my_company')
    op.drop_index(op.f('ix_my_company_fax'), table_name='my_company')
    op.drop_index(op.f('ix_my_company_email'), table_name='my_company')
    op.drop_index(op.f('ix_my_company_cif'), table_name='my_company')
    op.drop_table('my_company')
    # ### end Alembic commands ###
