"""Create Tables

Revision ID: 996b9a5c9829
Revises: 
Create Date: 2018-11-30 10:05:32.613062

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('actor_links',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('actorid', sa.Integer(), nullable=True),
    sa.Column('characterid', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='tvdb'
    )
    op.create_table('actors',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('actorid', sa.Integer(), nullable=True),
    sa.Column('actorname', sa.String(length=72), nullable=True),
    sa.Column('countryname', sa.String(length=36), nullable=True),
    sa.Column('countrytimezone', sa.String(length=72), nullable=True),
    sa.Column('birthday', sa.Date(), nullable=True),
    sa.Column('deathday', sa.Date(), nullable=True),
    sa.Column('gender', sa.String(length=6), nullable=True),
    sa.Column('mediumimage', sa.TEXT(), nullable=True),
    sa.Column('originalimage', sa.TEXT(), nullable=True),
    sa.Column('apilink', sa.TEXT(), nullable=True),
    sa.Column('url', sa.TEXT(), nullable=True),
    sa.Column('countrycode', sa.String(length=12), nullable=True),
    sa.Column('created_on', sa.DateTime(), nullable=True),
    sa.Column('updated_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='tvdb'
    )
    op.create_table('castdata',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('seriesid', sa.Integer(), nullable=True),
    sa.Column('characterid', sa.Integer(), nullable=True),
    sa.Column('actorid', sa.Integer(), nullable=True),
    sa.Column('url', sa.TEXT(), nullable=True),
    sa.Column('charactername', sa.String(length=250), nullable=True),
    sa.Column('mediumimage', sa.TEXT(), nullable=True),
    sa.Column('originalimage', sa.TEXT(), nullable=True),
    sa.Column('apilink', sa.TEXT(), nullable=True),
    sa.Column('tvmazelink', sa.TEXT(), nullable=True),
    sa.Column('created_on', sa.DateTime(), nullable=True),
    sa.Column('updated_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='tvdb'
    )
    op.create_table('epdata',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('episodeid', sa.BigInteger(), nullable=True),
    sa.Column('seriesId', sa.Unicode(length=64), nullable=True),
    sa.Column('airedSeason', sa.Integer(), nullable=True),
    sa.Column('airedSeasonID', sa.Integer(), nullable=True),
    sa.Column('airedEpisodeNumber', sa.Integer(), nullable=True),
    sa.Column('episodeName', sa.TEXT(), nullable=True),
    sa.Column('firstAired', sa.Date(), nullable=True),
    sa.Column('guestStars', sa.TEXT(), nullable=True),
    sa.Column('director', sa.TEXT(), nullable=True),
    sa.Column('directors', sa.TEXT(), nullable=True),
    sa.Column('writers', sa.TEXT(), nullable=True),
    sa.Column('overview', sa.TEXT(), nullable=True),
    sa.Column('language_episodeName', sa.String(length=32), nullable=True),
    sa.Column('language_overview', sa.String(length=32), nullable=True),
    sa.Column('productionCode', sa.TEXT(), nullable=True),
    sa.Column('showUrl', sa.TEXT(), nullable=True),
    sa.Column('lastUpdated', sa.Integer(), nullable=True),
    sa.Column('dvdDiscid', sa.Unicode(length=64), nullable=True),
    sa.Column('dvdSeason', sa.Integer(), nullable=True),
    sa.Column('dvdEpisodeNumber', sa.Integer(), nullable=True),
    sa.Column('dvdChapter', sa.Integer(), nullable=True),
    sa.Column('absoluteNumber', sa.Integer(), nullable=True),
    sa.Column('filename', sa.TEXT(), nullable=True),
    sa.Column('lastUpdatedBy', sa.Integer(), nullable=True),
    sa.Column('airsAfterSeason', sa.Integer(), nullable=True),
    sa.Column('airsBeforeSeason', sa.Integer(), nullable=True),
    sa.Column('airsBeforeEpisode', sa.Integer(), nullable=True),
    sa.Column('thumbAuthor', sa.Integer(), nullable=True),
    sa.Column('thumbAdded', sa.DateTime(), nullable=True),
    sa.Column('thumbWidth', sa.TEXT(), nullable=True),
    sa.Column('thumbHeigh', sa.TEXT(), nullable=True),
    sa.Column('imdbId', sa.String(length=64), nullable=True),
    sa.Column('siteRating', sa.Float(precision=53), nullable=True),
    sa.Column('siteRatingCount', sa.Float(precision=53), nullable=True),
    sa.Column('created_on', sa.DateTime(), nullable=True),
    sa.Column('updated_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='tvdb'
    )
    op.create_table('seriesdata',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('seriesId', sa.String(length=150), nullable=True),
    sa.Column('tvdbId', sa.Integer(), nullable=True),
    sa.Column('imdbId', sa.String(length=25), nullable=True),
    sa.Column('zap2itId', sa.TEXT(), nullable=True),
    sa.Column('networkId', sa.String(length=25), nullable=True),
    sa.Column('genre', sa.TEXT(), nullable=True),
    sa.Column('seriesName', sa.String(length=150), nullable=True),
    sa.Column('aliases', sa.TEXT(), nullable=True),
    sa.Column('status', sa.String(length=25), nullable=True),
    sa.Column('firstAired', sa.String(length=25), nullable=True),
    sa.Column('airsDayOfWeek', sa.String(length=72), nullable=True),
    sa.Column('airsTime', sa.String(length=25), nullable=True),
    sa.Column('runtime', sa.String(length=25), nullable=True),
    sa.Column('rating', sa.String(length=25), nullable=True),
    sa.Column('overview', sa.TEXT(), nullable=True),
    sa.Column('banner', sa.TEXT(), nullable=True),
    sa.Column('lastUpdated', sa.Integer(), nullable=True),
    sa.Column('added', sa.DateTime(), nullable=True),
    sa.Column('addedBy', sa.String(length=25), nullable=True),
    sa.Column('siteRating', sa.Float(precision=53), nullable=True),
    sa.Column('siteRatingCount', sa.Float(precision=53), nullable=True),
    sa.Column('slug', sa.TEXT(), nullable=True),
    sa.Column('created_on', sa.DateTime(), nullable=True),
    sa.Column('updated_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('seriesId'),
    schema='tvdb'
    )
    op.create_table('ep_links',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('seriesid', sa.Integer(), nullable=True),
    sa.Column('episodeid', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='tvdb'
    )
    op.create_table('tvnetworks',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('networkid', sa.String(length=12), nullable=True),
    sa.Column('networkname', sa.String(length=255), nullable=True),
    sa.Column('countryname', sa.String(length=255), nullable=True),
    sa.Column('countrycode', sa.String(length=4), nullable=True),
    sa.Column('countrytimezone', sa.String(length=25), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='tvdb'
    )
    op.create_table('tvwebchannels',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('webchannelname', sa.String(length=255), nullable=True),
    sa.Column('webchannelcountrycode', sa.String(length=4), nullable=True),
    sa.Column('webchannelcountryname', sa.String(length=255), nullable=True),
    sa.Column('webchannelcountrytimezone', sa.String(length=4), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='tvdb'
    )
    op.create_table('tvmaze_characterjson',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('seriesid', sa.Integer(), nullable=True),
    sa.Column('jdata', sa.Unicode(), nullable=True),
    sa.Column('created_on', sa.DateTime(), nullable=True),
    sa.Column('updated_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='updates'
    )
    op.create_table('tvmaze_episodejson',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('seriesid', sa.Integer(), nullable=True),
    sa.Column('jdata', sa.String(collation='SQL_Latin1_General_CP1_CI_AS'), nullable=True),
    sa.Column('created_on', sa.DateTime(), nullable=True),
    sa.Column('updated_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='updates'
    )
    op.create_table('tvmaze_seriesjson',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('seriesid', sa.Integer(), nullable=True),
    sa.Column('jdata', sa.String(collation='SQL_Latin1_General_CP1_CI_AS'), nullable=True),
    sa.Column('created_on', sa.DateTime(), nullable=True),
    sa.Column('updated_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    schema='updates'
    )
    op.create_table('tvupdatedata',
    sa.Column('seriesid', sa.BigInteger(), nullable=False),
    sa.Column('timestamp', sa.String(length=15), nullable=True),
    sa.PrimaryKeyConstraint('seriesid'),
    schema='updates'
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('tvupdatedata', schema='updates')
    op.drop_table('tvmaze_seriesjson', schema='updates')
    op.drop_table('tvmaze_episodejson', schema='updates')
    op.drop_table('tvmaze_characterjson', schema='updates')
    op.drop_table('tvwebchannels', schema='tvdb')
    op.drop_table('tvnetworks', schema='tvdb')
    op.drop_table('seriesdata', schema='tvdb')
    op.drop_table('epdata', schema='tvdb')
    op.drop_table('ep_links', schema='tvdb')
    op.drop_table('castdata', schema='tvdb')
    op.drop_table('actors', schema='tvdb')
    op.drop_table('actor_links', schema='tvdb')
    # ### end Alembic commands ###
