"""Create associative 'shows' table

Revision ID: cd523af12901
Revises: 25816af57307
Create Date: 2021-04-26 21:04:10.491904

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'cd523af12901'
down_revision = '25816af57307'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('shows',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('venue_id', sa.Integer(), nullable=False),
        sa.Column('artist_id', sa.Integer(), nullable=False),
        sa.Column('start_time', sa.DateTime(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(['artist_id'], ['artists.id'], ),
        sa.ForeignKeyConstraint(['venue_id'], ['venues.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###

    # ### populate database with test data ###
    op.execute("INSERT INTO shows (id, venue_id, artist_id, start_time) VALUES (101, 101, 101, '2020-03-27 18:10:00')")
    op.execute("INSERT INTO shows (id, venue_id, artist_id, start_time) VALUES (102, 101, 101, '2020-03-20 18:10:00')")
    op.execute("INSERT INTO shows (id, venue_id, artist_id, start_time) VALUES (103, 101, 101, '2020-03-13 18:10:00')")
    op.execute("INSERT INTO shows (id, venue_id, artist_id, start_time) VALUES (104, 102, 103, '2021-04-30 20:00')")
    op.execute("INSERT INTO shows (id, venue_id, artist_id, start_time) VALUES (105, 103, 101, '2021-12-01 22:00')")
    ## problem: inserted this way, the hour always has the timezone of the server

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