from sqlalchemy import BigInteger, Column, Date, DateTime, ForeignKey, Index, Integer, String, TEXT, Unicode, Float, Table
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
metadata = Base.metadata


class ActorLink(Base):
    __tablename__ = 'actor_links'
 
    id = Column(BigInteger, primary_key=True)
    actorid = Column(Integer)
    characterid = Column(Integer)

    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class Actor(Base):
    __tablename__ = 'actors'
 
    id = Column(BigInteger, primary_key=True)
    actorid = Column(Integer)
    actorname = Column(String(72))
    countryname = Column(String(36))
    countrytimezone = Column(String(72))
    birthday = Column(Date)
    deathday = Column(Date)
    gender = Column(String(6))
    mediumimage = Column(TEXT)
    originalimage = Column(TEXT)
    apilink = Column(TEXT)
    url = Column(TEXT)
    countrycode = Column(String(12))
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class Castdatum(Base):
    __tablename__ = 'castdata'
 
    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    characterid = Column(Integer)
    actorid = Column(Integer)
    url = Column(TEXT)
    charactername = Column(String(250))
    mediumimage = Column(TEXT)
    originalimage = Column(TEXT)
    apilink = Column(TEXT)
    tvmazelink = Column(TEXT)
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class Epdatum(Base):
    __tablename__ = 'epdata'
 
    id = Column(BigInteger, primary_key=True)
    episodeid = Column(BigInteger)
    seriesId = Column(Unicode(64))
    airedSeason = Column(Integer)
    airedSeasonID = Column(Integer)
    airedEpisodeNumber = Column(Integer)
    episodeName = Column(TEXT)
    firstAired = Column(Date)
    guestStars = Column(TEXT)
    director = Column(TEXT)
    directors = Column(TEXT)
    writers = Column(TEXT)
    overview = Column(TEXT)
    language_episodeName = Column(String(32))
    language_overview = Column(String(32))
    productionCode = Column(TEXT)
    showUrl = Column(TEXT)
    lastUpdated = Column(Integer)
    dvdDiscid = Column(Unicode(64))
    dvdSeason = Column(Integer)
    dvdEpisodeNumber = Column(Integer)
    dvdChapter = Column(Integer)
    absoluteNumber = Column(Integer)
    filename = Column(TEXT)
    lastUpdatedBy = Column(Integer)
    airsAfterSeason = Column(Integer)
    airsBeforeSeason = Column(Integer)
    airsBeforeEpisode = Column(Integer)
    thumbAuthor = Column(Integer)
    thumbAdded = Column(DateTime)
    thumbWidth = Column(TEXT)
    thumbHeigh = Column(TEXT)
    imdbId = Column(String(64))
    siteRating = Column(Float(53))
    siteRatingCount = Column(Float(53))
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class Seriesdatum(Base):
    __tablename__ = 'seriesdata'
 
    id = Column(BigInteger, primary_key=True)
    seriesId = Column(String(150), unique=True)
    tvdbId = Column(Integer)
    tvrageId = Column(Integer)
    imdbId = Column(String(25))
    zap2itId = Column(TEXT)
    networkId = Column(String(25))
    genre = Column(TEXT)
    seriesName = Column(String(150))
    aliases = Column(TEXT)
    status = Column(String(25))
    firstAired = Column(String(25))
    airsDayOfWeek = Column(String(72))
    airsTime = Column(String(25))
    runtime = Column(String(25))
    rating = Column(String(25))
    overview = Column(TEXT)
    banner = Column(TEXT)
    lastUpdated = Column(Integer)
    added = Column(DateTime)
    addedBy = Column(String(25))
    siteRating = Column(Float(53))
    siteRatingCount = Column(Float(53))
    slug = Column(TEXT)
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class Tvnetwork(Base):
    __tablename__ = 'tvnetworks'
 
    id = Column(BigInteger, primary_key=True)
    networkid = Column(String(12))
    networkname = Column(String(255))
    countryname = Column(String(255))
    countrycode = Column(String(4))
    countrytimezone = Column(String(25))


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class Tvwebchannel(Base):
    __tablename__ = 'tvwebchannels'
 
    id = Column(BigInteger, primary_key=True)
    webchannelname = Column(String(255))
    webchannelcountrycode = Column(String(4))
    webchannelcountryname = Column(String(255))
    webchannelcountrytimezone = Column(String(4))



    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class EpLink(Base):
    __tablename__ = 'ep_links'
    __table_args__ = (
        Index('NonClusteredIndex-20180826-114123', 'seriesid', 'episodeid'),
    )

    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    episodeid = Column(Integer)

    #seriesdatum = relationship('Seriesdatum')

	
    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbActorLink(Base):
    __tablename__ = 'actor_links'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    actorid = Column(Integer)
    characterid = Column(Integer)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbActor(Base):
    __tablename__ = 'actors'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    actorid = Column(Integer)
    actorname = Column(String(72))
    countryname = Column(String(36))
    countrytimezone = Column(String(72))
    birthday = Column(Date)
    deathday = Column(Date)
    gender = Column(String(6))
    mediumimage = Column(TEXT)
    originalimage = Column(TEXT)
    apilink = Column(TEXT)
    url = Column(TEXT)
    countrycode = Column(String(12))
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbCastdatum(Base):
    __tablename__ = 'castdata'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    characterid = Column(Integer)
    actorid = Column(Integer)
    url = Column(TEXT)
    charactername = Column(String(250))
    mediumimage = Column(TEXT)
    originalimage = Column(TEXT)
    apilink = Column(TEXT)
    tvmazelink = Column(TEXT)
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbEpLink(Base):
    __tablename__ = 'ep_links'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    episodeid = Column(Integer)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbEpdatum(Base):
    __tablename__ = 'epdata'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    episodeid = Column(BigInteger)
    seriesId = Column(Unicode(64))
    airedSeason = Column(Integer)
    airedSeasonID = Column(Integer)
    airedEpisodeNumber = Column(Integer)
    episodeName = Column(TEXT)
    firstAired = Column(Date)
    guestStars = Column(TEXT)
    director = Column(TEXT)
    directors = Column(TEXT)
    writers = Column(TEXT)
    overview = Column(TEXT)
    language_episodeName = Column(String(32))
    language_overview = Column(String(32))
    productionCode = Column(TEXT)
    showUrl = Column(TEXT)
    lastUpdated = Column(Integer)
    dvdDiscid = Column(Unicode(64))
    dvdSeason = Column(Integer)
    dvdEpisodeNumber = Column(Integer)
    dvdChapter = Column(Integer)
    absoluteNumber = Column(Integer)
    filename = Column(TEXT)
    lastUpdatedBy = Column(Integer)
    airsAfterSeason = Column(Integer)
    airsBeforeSeason = Column(Integer)
    airsBeforeEpisode = Column(Integer)
    thumbAuthor = Column(Integer)
    thumbAdded = Column(DateTime)
    thumbWidth = Column(TEXT)
    thumbHeigh = Column(TEXT)
    imdbId = Column(String(64))
    siteRating = Column(Float(53))
    siteRatingCount = Column(Float(53))
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbSeriesdatum(Base):
    __tablename__ = 'seriesdata'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    seriesId = Column(String(150), unique=True)
    tvdbId = Column(Integer)
    tvrageId = Column(Integer)
    imdbId = Column(String(25))
    zap2itId = Column(TEXT)
    networkId = Column(String(25))
    genre = Column(TEXT)
    seriesName = Column(String(150))
    aliases = Column(TEXT)
    status = Column(String(25))
    firstAired = Column(String(25))
    airsDayOfWeek = Column(String(72))
    airsTime = Column(String(25))
    runtime = Column(String(25))
    rating = Column(String(25))
    overview = Column(TEXT)
    banner = Column(TEXT)
    lastUpdated = Column(Integer)
    added = Column(DateTime)
    addedBy = Column(String(25))
    siteRating = Column(Float(53))
    siteRatingCount = Column(Float(53))
    slug = Column(TEXT)
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbTvnetwork(Base):
    __tablename__ = 'tvnetworks'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    networkid = Column(String(12))
    networkname = Column(String(255))
    countryname = Column(String(255))
    countrycode = Column(String(4))
    countrytimezone = Column(String(25))


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class TvdbTvwebchannel(Base):
    __tablename__ = 'tvwebchannels'
    __table_args__ = {'schema': 'tvdb'}

    id = Column(BigInteger, primary_key=True)
    webchannelname = Column(String(255))
    webchannelcountrycode = Column(String(4))
    webchannelcountryname = Column(String(255))
    webchannelcountrytimezone = Column(String(4))

	
    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class UpdatesTvmazeCharacterjson(Base):
    __tablename__ = 'tvmaze_characterjson'
    __table_args__ = {'schema': 'updates'}

    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    jdata = Column(Unicode)
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class UpdatesTvmazeEpisodejson(Base):
    __tablename__ = 'tvmaze_episodejson'
    __table_args__ = {'schema': 'updates'}

    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    jdata = Column(String(collation='SQL_Latin1_General_CP1_CI_AS'))
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class UpdatesTvmazeSeriesjson(Base):
    __tablename__ = 'tvmaze_seriesjson'
    __table_args__ = {'schema': 'updates'}

    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    jdata = Column(String(collation='SQL_Latin1_General_CP1_CI_AS'))
    created_on = Column(DateTime)
    updated_on = Column(DateTime)


    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

class UpdatesTvupdatedatum(Base):
    __tablename__ = 'tvupdatedata'
    __table_args__ = {'schema': 'updates'}

    id = Column(BigInteger, primary_key=True)
    seriesid = Column(Integer)
    timestamp = Column(String(15))

    def __repr__(self):
        return u'<{self.__class__.__name__}: {self.id}>'.format(self=self)

