"""Add chinook models

Revision ID: 13d5b7bf4214
Revises: b7f884f5fc23
Create Date: 2020-06-17 22:23:58.202580

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '13d5b7bf4214'
down_revision = 'b7f884f5fc23'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('Artist',
    sa.Column('ArtistId', sa.Integer(), nullable=False),
    sa.Column('Name', sa.String(length=120), nullable=True),
    sa.PrimaryKeyConstraint('ArtistId')
    )
    op.create_table('Employee',
    sa.Column('EmployeeId', sa.Integer(), nullable=False),
    sa.Column('LastName', sa.String(length=20), nullable=False),
    sa.Column('FirstName', sa.String(length=20), nullable=False),
    sa.Column('Title', sa.String(length=30), nullable=True),
    sa.Column('ReportsTo', sa.Integer(), nullable=True),
    sa.Column('BirthDate', sa.DateTime(), nullable=True),
    sa.Column('HireDate', sa.DateTime(), nullable=True),
    sa.Column('Address', sa.String(length=70), nullable=True),
    sa.Column('City', sa.String(length=40), nullable=True),
    sa.Column('State', sa.String(length=40), nullable=True),
    sa.Column('Country', sa.String(length=40), nullable=True),
    sa.Column('PostalCode', sa.String(length=10), nullable=True),
    sa.Column('Phone', sa.String(length=24), nullable=True),
    sa.Column('Fax', sa.String(length=24), nullable=True),
    sa.Column('Email', sa.String(length=60), nullable=True),
    sa.ForeignKeyConstraint(['ReportsTo'], ['Employee.EmployeeId'], ),
    sa.PrimaryKeyConstraint('EmployeeId')
    )
    op.create_index(op.f('ix_Employee_ReportsTo'), 'Employee', ['ReportsTo'], unique=False)
    op.create_table('Genre',
    sa.Column('GenreId', sa.Integer(), nullable=False),
    sa.Column('Name', sa.String(length=120), nullable=True),
    sa.PrimaryKeyConstraint('GenreId')
    )
    op.create_table('MediaType',
    sa.Column('MediaTypeId', sa.Integer(), nullable=False),
    sa.Column('Name', sa.String(length=120), nullable=True),
    sa.PrimaryKeyConstraint('MediaTypeId')
    )
    op.create_table('Playlist',
    sa.Column('PlaylistId', sa.Integer(), nullable=False),
    sa.Column('Name', sa.String(length=120), nullable=True),
    sa.PrimaryKeyConstraint('PlaylistId')
    )
    op.create_table('Album',
    sa.Column('AlbumId', sa.Integer(), nullable=False),
    sa.Column('Title', sa.String(length=160), nullable=False),
    sa.Column('ArtistId', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['ArtistId'], ['Artist.ArtistId'], ),
    sa.PrimaryKeyConstraint('AlbumId')
    )
    op.create_index(op.f('ix_Album_ArtistId'), 'Album', ['ArtistId'], unique=False)
    op.create_table('Customer',
    sa.Column('CustomerId', sa.Integer(), nullable=False),
    sa.Column('FirstName', sa.String(length=40), nullable=False),
    sa.Column('LastName', sa.String(length=20), nullable=False),
    sa.Column('Company', sa.String(length=80), nullable=True),
    sa.Column('Address', sa.String(length=70), nullable=True),
    sa.Column('City', sa.String(length=40), nullable=True),
    sa.Column('State', sa.String(length=40), nullable=True),
    sa.Column('Country', sa.String(length=40), nullable=True),
    sa.Column('PostalCode', sa.String(length=10), nullable=True),
    sa.Column('Phone', sa.String(length=24), nullable=True),
    sa.Column('Fax', sa.String(length=24), nullable=True),
    sa.Column('Email', sa.String(length=60), nullable=False),
    sa.Column('SupportRepId', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['SupportRepId'], ['Employee.EmployeeId'], ),
    sa.PrimaryKeyConstraint('CustomerId')
    )
    op.create_index(op.f('ix_Customer_SupportRepId'), 'Customer', ['SupportRepId'], unique=False)
    op.create_table('Invoice',
    sa.Column('InvoiceId', sa.Integer(), nullable=False),
    sa.Column('CustomerId', sa.Integer(), nullable=False),
    sa.Column('InvoiceDate', sa.DateTime(), nullable=False),
    sa.Column('BillingAddress', sa.String(length=70), nullable=True),
    sa.Column('BillingCity', sa.String(length=40), nullable=True),
    sa.Column('BillingState', sa.String(length=40), nullable=True),
    sa.Column('BillingCountry', sa.String(length=40), nullable=True),
    sa.Column('BillingPostalCode', sa.String(length=10), nullable=True),
    sa.Column('Total', sa.Numeric(precision=10, scale=2), nullable=False),
    sa.ForeignKeyConstraint(['CustomerId'], ['Customer.CustomerId'], ),
    sa.PrimaryKeyConstraint('InvoiceId')
    )
    op.create_index(op.f('ix_Invoice_CustomerId'), 'Invoice', ['CustomerId'], unique=False)
    op.create_table('Track',
    sa.Column('TrackId', sa.Integer(), nullable=False),
    sa.Column('Name', sa.String(length=200), nullable=False),
    sa.Column('AlbumId', sa.Integer(), nullable=True),
    sa.Column('MediaTypeId', sa.Integer(), nullable=False),
    sa.Column('GenreId', sa.Integer(), nullable=True),
    sa.Column('Composer', sa.String(length=220), nullable=True),
    sa.Column('Milliseconds', sa.Integer(), nullable=False),
    sa.Column('Bytes', sa.Integer(), nullable=True),
    sa.Column('UnitPrice', sa.Numeric(precision=10, scale=2), nullable=False),
    sa.ForeignKeyConstraint(['AlbumId'], ['Album.AlbumId'], ),
    sa.ForeignKeyConstraint(['GenreId'], ['Genre.GenreId'], ),
    sa.ForeignKeyConstraint(['MediaTypeId'], ['MediaType.MediaTypeId'], ),
    sa.PrimaryKeyConstraint('TrackId')
    )
    op.create_index(op.f('ix_Track_AlbumId'), 'Track', ['AlbumId'], unique=False)
    op.create_index(op.f('ix_Track_GenreId'), 'Track', ['GenreId'], unique=False)
    op.create_index(op.f('ix_Track_MediaTypeId'), 'Track', ['MediaTypeId'], unique=False)
    op.create_table('InvoiceLine',
    sa.Column('InvoiceLineId', sa.Integer(), nullable=False),
    sa.Column('InvoiceId', sa.Integer(), nullable=False),
    sa.Column('TrackId', sa.Integer(), nullable=False),
    sa.Column('UnitPrice', sa.Numeric(precision=10, scale=2), nullable=False),
    sa.Column('Quantity', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['InvoiceId'], ['Invoice.InvoiceId'], ),
    sa.ForeignKeyConstraint(['TrackId'], ['Track.TrackId'], ),
    sa.PrimaryKeyConstraint('InvoiceLineId')
    )
    op.create_index(op.f('ix_InvoiceLine_InvoiceId'), 'InvoiceLine', ['InvoiceId'], unique=False)
    op.create_index(op.f('ix_InvoiceLine_TrackId'), 'InvoiceLine', ['TrackId'], unique=False)
    op.create_table('PlaylistTrack',
    sa.Column('PlaylistId', sa.Integer(), nullable=False),
    sa.Column('TrackId', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['PlaylistId'], ['Playlist.PlaylistId'], ),
    sa.ForeignKeyConstraint(['TrackId'], ['Track.TrackId'], ),
    sa.PrimaryKeyConstraint('PlaylistId', 'TrackId')
    )
    op.create_index(op.f('ix_PlaylistTrack_TrackId'), 'PlaylistTrack', ['TrackId'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_PlaylistTrack_TrackId'), table_name='PlaylistTrack')
    op.drop_table('PlaylistTrack')
    op.drop_index(op.f('ix_InvoiceLine_TrackId'), table_name='InvoiceLine')
    op.drop_index(op.f('ix_InvoiceLine_InvoiceId'), table_name='InvoiceLine')
    op.drop_table('InvoiceLine')
    op.drop_index(op.f('ix_Track_MediaTypeId'), table_name='Track')
    op.drop_index(op.f('ix_Track_GenreId'), table_name='Track')
    op.drop_index(op.f('ix_Track_AlbumId'), table_name='Track')
    op.drop_table('Track')
    op.drop_index(op.f('ix_Invoice_CustomerId'), table_name='Invoice')
    op.drop_table('Invoice')
    op.drop_index(op.f('ix_Customer_SupportRepId'), table_name='Customer')
    op.drop_table('Customer')
    op.drop_index(op.f('ix_Album_ArtistId'), table_name='Album')
    op.drop_table('Album')
    op.drop_table('Playlist')
    op.drop_table('MediaType')
    op.drop_table('Genre')
    op.drop_index(op.f('ix_Employee_ReportsTo'), table_name='Employee')
    op.drop_table('Employee')
    op.drop_table('Artist')
    # ### end Alembic commands ###
