[mythtv] Use callsign for scheduling

Brian May bam at snoopy.apana.org.au
Tue Apr 20 19:15:01 EDT 2004

>>>>> "David" == David Engel <gigem at comcast.net> writes:

    David> OK, then quit complaining and make a concrete proposal (or
    David> better yet, a patch) to do this.  Please make sure it
    David> handles upgrading and backwards and forwards compatibility.

Like I proposed earlier (although I may not have time to do it),
create a new "station" table. To do this and maintain compatibility,
how about the following?

When upgrading database:

1. Create new table, call it station. This table has "stationid",
   "callsign", and "xmltvid" fields.

2. Automatically file the "station" table based on the existing
   "channel" table. Automatically allocate stationid's for each

   station=(prev+1), callsign=channel.callsign, xmltvid=channel.xmltvid
      for every unique callsign

3. Add "stationid" to "channel" table, and set it to the stationid
   used in 2. Do not delete "callsign" or "xmltvid" yet, they are for
   backwords compatibility.

When making changes using mythtv-setup:

<insert text="clever stuff here">
In particular, when updating callsign or xmltvid for a channel, update
both channel table and station table.

Alternatively, just have a new section for updating "stations"
independently of the "channels" and skip the next section on cross
checking information.

For the paranoid, and if appropriate, whenever starting up:

1. Check the "channel" table. 

   * In particular, ensure that the "callsign" value corresponds with
     the "stationid", as per the "station" table. If it doesn't, then
     the user may have updated the callsign in an older version, or
     manually updated the database.

     ie. check:

        WHERE channel.stationid == station.stationid

   * Similarly, check that the "xmltvid" value matches the "xmltvid"
     value in the "station" table.

     ie. check:

        WHERE channel.stationid == station.stationid

It probably wouldn't hurt if these checks are not done, but it could
be confusing (if you aren't expecting the callsign could be different
depending on what version of mythtv you use). It is unclear what to do
if any of the above checks fail, probably the best thing would be just
to log a warning. If you try to automagically correct errors, you
might update the wrong thing.

When ability to run older versions of mythtv no longer required:

1. delete the "callsign" and "xmltvid" fields in "channel", and remove
  above checks.

(Disclaimer: my examples may look like SQL extracts, but probably
Brian May <bam at snoopy.apana.org.au>

More information about the mythtv-dev mailing list