MythTV  master
mythtv/libs/libmythtv/dbcheck.cpp
Go to the documentation of this file.
1 #include "mythconfig.h"
2 
3 #include <cstdio>
4 #include <iostream>
5 using namespace std;
6 
7 #include <QString>
8 #include <QSqlError>
9 #include "dbcheck.h"
10 
11 #include "mythversion.h"
12 #include "dbutil.h"
13 #include "mythcorecontext.h"
14 #include "schemawizard.h"
15 #include "mythdb.h"
16 #include "mythlogging.h"
17 #include "videodbcheck.h" // for 1267
18 #include "compat.h"
19 #include "recordingrule.h"
20 #include "recordingprofile.h"
21 #include "recordinginfo.h"
22 #include "cardutil.h"
23 
24 // TODO convert all dates to UTC
25 
26 #define MINIMUM_DBMS_VERSION 5,0,15
27 
29 
30 static bool UpdateDBVersionNumber(const QString &newnumber, QString &dbver);
31 static bool performActualUpdate(
32  const char **updates, const char *version, QString &dbver);
33 static bool doUpgradeTVDatabaseSchema(void);
34 
35 #if CONFIG_SYSTEMD_NOTIFY
36 #include <systemd/sd-daemon.h>
37 #define db_sd_notify(x) \
38  if (informSystemd) \
39  (void)sd_notify(0, "STATUS=Database update " x);
40 #else
41 #define db_sd_notify(x)
42 #endif
43 
358 static bool UpdateDBVersionNumber(const QString &newnumber, QString &dbver)
359 {
360  // delete old schema version
361  MSqlQuery query(MSqlQuery::InitCon());
362 
363  QString thequery = "DELETE FROM settings WHERE value='DBSchemaVer';";
364  query.prepare(thequery);
365 
366  if (!query.exec())
367  {
368  QString msg =
369  QString("DB Error (Deleting old DB version number): \n"
370  "Query was: %1 \nError was: %2 \nnew version: %3")
371  .arg(thequery)
372  .arg(MythDB::DBErrorMessage(query.lastError()))
373  .arg(newnumber);
374  LOG(VB_GENERAL, LOG_ERR, msg);
375  return false;
376  }
377 
378  // set new schema version
379  thequery = QString("INSERT INTO settings (value, data, hostname) "
380  "VALUES ('DBSchemaVer', %1, NULL);").arg(newnumber);
381  query.prepare(thequery);
382 
383  if (!query.exec())
384  {
385  QString msg =
386  QString("DB Error (Setting new DB version number): \n"
387  "Query was: %1 \nError was: %2 \nnew version: %3")
388  .arg(thequery)
389  .arg(MythDB::DBErrorMessage(query.lastError()))
390  .arg(newnumber);
391  LOG(VB_GENERAL, LOG_ERR, msg);
392  return false;
393  }
394 
395  dbver = newnumber;
396 
397  return true;
398 }
399 
406 static bool performUpdateSeries(const char **updates)
407 {
408  MSqlQuery query(MSqlQuery::InitCon());
409 
410  int counter = 0;
411  const char *thequery = updates[counter];
412 
413  while (thequery != nullptr)
414  {
415  if (strlen(thequery) && !query.exec(thequery))
416  {
417  QString msg =
418  QString("DB Error (Performing database upgrade): \n"
419  "Query was: %1 \nError was: %2")
420  .arg(thequery)
421  .arg(MythDB::DBErrorMessage(query.lastError()));
422  LOG(VB_GENERAL, LOG_ERR, msg);
423  return false;
424  }
425 
426  counter++;
427  thequery = updates[counter];
428  }
429 
430  return true;
431 }
432 
443  const char **updates, const char *version, QString &dbver)
444 {
445  MSqlQuery query(MSqlQuery::InitCon());
446 
447  LOG(VB_GENERAL, LOG_CRIT, QString("Upgrading to MythTV schema version ") +
448  version);
449 
450  if (!performUpdateSeries(updates))
451  return false;
452 
453  if (!UpdateDBVersionNumber(version, dbver))
454  return false;
455 
456  return true;
457 }
458 
473 bool UpgradeTVDatabaseSchema(const bool upgradeAllowed,
474  const bool upgradeIfNoUI,
475  const bool informSystemd)
476 {
477 #ifdef IGNORE_SCHEMA_VER_MISMATCH
478  return true;
479 #endif
480 #if CONFIG_SYSTEMD_NOTIFY == 0
481  Q_UNUSED(informSystemd);
482 #endif
483  SchemaUpgradeWizard *schema_wizard = nullptr;
484 
485  // Suppress DB messages and turn of the settings cache,
486  // These are likely to confuse the users and the code, respectively.
487  GetMythDB()->SetSuppressDBMessages(true);
489 
490  // Get the schema upgrade lock
491  MSqlQuery query(MSqlQuery::InitCon());
492  bool locked = DBUtil::TryLockSchema(query, 1);
493  for (uint i = 0; i < 2*60 && !locked; i++)
494  {
495  db_sd_notify("waiting for lock");
496  LOG(VB_GENERAL, LOG_INFO, "Waiting for database schema upgrade lock");
497  locked = DBUtil::TryLockSchema(query, 1);
498  if (locked)
499  LOG(VB_GENERAL, LOG_INFO, "Got schema upgrade lock");
500  }
501  if (!locked)
502  {
503  LOG(VB_GENERAL, LOG_INFO, "Failed to get schema upgrade lock");
504  goto upgrade_error_exit;
505  }
506 
507  // Determine if an upgrade is needed
508  schema_wizard = SchemaUpgradeWizard::Get(
509  "DBSchemaVer", "MythTV", currentDatabaseVersion);
510  if (schema_wizard->Compare() == 0) // DB schema is what we need it to be..
511  goto upgrade_ok_exit;
512 
513  if (!upgradeAllowed)
514  LOG(VB_GENERAL, LOG_WARNING, "Not allowed to upgrade the database.");
515 
516  db_sd_notify("waiting for user input");
517  // Pop up messages, questions, warnings, etc.
518  switch (schema_wizard->PromptForUpgrade(
519  "TV", upgradeAllowed, upgradeIfNoUI, MINIMUM_DBMS_VERSION))
520  {
522  goto upgrade_ok_exit;
523  case MYTH_SCHEMA_ERROR:
524  case MYTH_SCHEMA_EXIT:
525  goto upgrade_error_exit;
526  case MYTH_SCHEMA_UPGRADE:
527  break;
528  }
529 
530  LOG(VB_GENERAL, LOG_DEBUG, QString("Newest MythTV Schema Version : %1")
531  .arg(currentDatabaseVersion));
532 
533  // Upgrade the schema
534  db_sd_notify("upgrading database");
536  {
537  LOG(VB_GENERAL, LOG_ERR, "Database schema upgrade failed.");
538  goto upgrade_error_exit;
539  }
540 
541  LOG(VB_GENERAL, LOG_INFO, "Database schema upgrade complete.");
542 
543  // On any exit we want to re-enable the DB messages so errors
544  // are reported and we want to make sure the setting cache is
545  // enabled for good performance and we must unlock the schema
546  // lock. We use gotos with labels so it's impossible to miss
547  // these steps.
548  upgrade_ok_exit:
549  db_sd_notify("success");
550  GetMythDB()->SetSuppressDBMessages(false);
552  if (locked)
553  DBUtil::UnlockSchema(query);
554  return true;
555 
556  upgrade_error_exit:
557  db_sd_notify("failed");
558  GetMythDB()->SetSuppressDBMessages(false);
560  if (locked)
561  DBUtil::UnlockSchema(query);
562  return false;
563 }
564 
578 static bool doUpgradeTVDatabaseSchema(void)
579 {
580  QString dbver = gCoreContext->GetSetting("DBSchemaVer");
581 
582  if (dbver == currentDatabaseVersion)
583  {
584  return true;
585  }
586 
587  // Don't rely on this, please specify these when creating the database.
588  {
589  MSqlQuery query(MSqlQuery::InitCon());
590  if (!query.exec(QString("ALTER DATABASE %1 DEFAULT "
591  "CHARACTER SET utf8 COLLATE utf8_general_ci;")
593  {
594  MythDB::DBError("UpgradeTVDatabaseSchema -- alter charset", query);
595  }
596  }
597 
598  if (DBUtil::IsNewDatabase())
599  {
600  if (!InitializeMythSchema())
601  return false;
602  dbver = gCoreContext->GetSetting("DBSchemaVer");
603  }
604 
605  if (dbver.isEmpty() || dbver.toInt() < 1027)
606  {
607  LOG(VB_GENERAL, LOG_ERR, "Unrecognized database schema version. "
608  "Unable to upgrade database.");
609  return false;
610  }
611  else if (dbver.toInt() < 1244)
612  {
613  LOG(VB_GENERAL, LOG_ERR, "Your database version is too old to upgrade "
614  "with this version of MythTV. You will need "
615  "to use mythtv-setup from MythTV 0.22, 0.23, "
616  "or 0.24 to upgrade your database before "
617  "upgrading to this version of MythTV.");
618  return false;
619  }
620 
621  if (dbver == "1244")
622  {
623  const char *updates[] = {
624 "ALTER TABLE cardinput DROP COLUMN freetoaironly;",
625 "ALTER TABLE cardinput DROP COLUMN radioservices;",
626 nullptr
627 };
628  if (!performActualUpdate(updates, "1245", dbver))
629  return false;
630  }
631 
632  if (dbver == "1245")
633  {
634  const char *updates[] = {
635 "DELETE FROM capturecard WHERE cardtype = 'DBOX2';",
636 "DELETE FROM profilegroups WHERE cardtype = 'DBOX2';",
637 "ALTER TABLE capturecard DROP COLUMN dbox2_port;",
638 "ALTER TABLE capturecard DROP COLUMN dbox2_httpport;",
639 "ALTER TABLE capturecard DROP COLUMN dbox2_host;",
640 nullptr
641 };
642  if (!performActualUpdate(updates, "1246", dbver))
643  return false;
644  }
645 
646  if (dbver == "1246")
647  {
648  const char *updates[] = {
649 "ALTER TABLE recorded ADD COLUMN bookmarkupdate timestamp default 0 NOT NULL",
650 "UPDATE recorded SET bookmarkupdate = lastmodified+1 WHERE bookmark = 1",
651 "UPDATE recorded SET bookmarkupdate = lastmodified WHERE bookmark = 0",
652 nullptr
653 };
654  if (!performActualUpdate(updates, "1247", dbver))
655  return false;
656  }
657 
658  if (dbver == "1247")
659  {
660  const char *updates[] = {
661 "INSERT INTO profilegroups SET name = \"Import Recorder\", cardtype = 'IMPORT', is_default = 1;",
662 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 14;",
663 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 14;",
664 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 14;",
665 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 14;",
666 nullptr
667 };
668  if (!performActualUpdate(updates, "1248", dbver))
669  return false;
670  }
671 
672  if (dbver == "1248")
673  {
674  const char *updates[] = {
675 "DELETE FROM keybindings WHERE action = 'CUSTOMEDIT' "
676  "AND context = 'TV Frontend' AND keylist = 'E';",
677 nullptr
678 };
679  if (!performActualUpdate(updates, "1249", dbver))
680  return false;
681  }
682 
683  if (dbver == "1249")
684  {
685  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1250");
686 
687  MSqlQuery select(MSqlQuery::InitCon());
688  select.prepare("SELECT hostname, data FROM settings "
689  " WHERE value = 'StickyKeys'");
690 
691  if (!select.exec())
692  {
693  MythDB::DBError("Unable to retrieve StickyKeys values.", select);
694  }
695  else
696  {
697  MSqlQuery update(MSqlQuery::InitCon());
698  while (select.next())
699  {
700  QString hostname = select.value(0).toString();
701  QString sticky_keys = select.value(1).toString();
702 
703  if ("1" == sticky_keys)
704  {
705  // Only remap the keys if they're currently set to defaults
706  update.prepare("UPDATE keybindings "
707  " SET keylist = :KEYS "
708  " WHERE context = 'TV Playback' AND "
709  " action = :ACTION AND "
710  " hostname = :HOSTNAME AND "
711  " keylist = :DEFAULT_KEYS");
712 
713  QString keylist = "";
714  QString action = "SEEKFFWD";
715  QString default_keys = "Right";
716 
717  update.bindValue(":KEYS", keylist);
718  update.bindValue(":ACTION", action);
719  update.bindValue(":HOSTNAME", hostname);
720  update.bindValue(":DEFAULT_KEYS", default_keys);
721  if (!update.exec())
722  MythDB::DBError("Unable to update keybindings",
723  update);
724 
725  keylist = "";
726  action = "SEEKRWND";
727  default_keys = "Left";
728 
729  update.bindValue(":KEYS", keylist);
730  update.bindValue(":ACTION", action);
731  update.bindValue(":HOSTNAME", hostname);
732  update.bindValue(":DEFAULT_KEYS", default_keys);
733  if (!update.exec())
734  MythDB::DBError("Unable to update keybindings",
735  update);
736 
737  keylist = ">,.,Right";
738  action = "FFWDSTICKY";
739  default_keys = ">,.";
740 
741  update.bindValue(":KEYS", keylist);
742  update.bindValue(":ACTION", action);
743  update.bindValue(":HOSTNAME", hostname);
744  update.bindValue(":DEFAULT_KEYS", default_keys);
745  if (!update.exec())
746  MythDB::DBError("Unable to update keybindings",
747  update);
748 
749  keylist = ",,<,Left";
750  action = "RWNDSTICKY";
751  default_keys = ",,<";
752 
753  update.bindValue(":KEYS", keylist);
754  update.bindValue(":ACTION", action);
755  update.bindValue(":HOSTNAME", hostname);
756  update.bindValue(":DEFAULT_KEYS", default_keys);
757  if (!update.exec())
758  MythDB::DBError("Unable to update keybindings",
759  update);
760  }
761  }
762  }
763 
764  if (!UpdateDBVersionNumber("1250", dbver))
765  return false;
766  }
767 
768  if (dbver == "1250")
769  {
770  const char *updates[] = {
771 "UPDATE recorded SET bookmark = 1 WHERE bookmark != 0;",
772 nullptr
773 };
774  if (!performActualUpdate(updates, "1251", dbver))
775  return false;
776  }
777 
778  if (dbver == "1251")
779  {
780  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1252");
781 
782  MSqlQuery query(MSqlQuery::InitCon());
783  query.prepare("SHOW INDEX FROM recgrouppassword");
784 
785  if (!query.exec())
786  {
787  MythDB::DBError("Unable to retrieve current indices on "
788  "recgrouppassword.", query);
789  }
790  else
791  {
792  while (query.next())
793  {
794  QString index_name = query.value(2).toString();
795 
796  if ("recgroup" == index_name)
797  {
798  MSqlQuery update(MSqlQuery::InitCon());
799  update.prepare("ALTER TABLE recgrouppassword "
800  " DROP INDEX recgroup");
801 
802  if (!update.exec())
803  MythDB::DBError("Unable to drop duplicate index on "
804  "recgrouppassword. Ignoring.",
805  update);
806  break;
807  }
808  }
809  }
810 
811  if (!UpdateDBVersionNumber("1252", dbver))
812  return false;
813  }
814 
815  if (dbver == "1252")
816  {
817  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1253");
818 
819  MSqlQuery select(MSqlQuery::InitCon());
820  select.prepare("SELECT hostname, data FROM settings "
821  " WHERE value = 'StickyKeys'");
822 
823  if (!select.exec())
824  {
825  MythDB::DBError("Unable to retrieve StickyKeys values.", select);
826  }
827  else
828  {
829  MSqlQuery update(MSqlQuery::InitCon());
830  while (select.next())
831  {
832  QString hostname = select.value(0).toString();
833  QString sticky_keys = select.value(1).toString();
834 
835  if ("1" == sticky_keys)
836  {
837  // Only remap the keys if they're currently set to defaults
838  update.prepare("UPDATE keybindings "
839  " SET keylist = :KEYS "
840  " WHERE context = 'TV Playback' AND "
841  " action = :ACTION AND "
842  " hostname = :HOSTNAME AND "
843  " keylist = :DEFAULT_KEYS");
844 
845  QString keylist = ">,.";
846  QString action = "FFWDSTICKY";
847  QString default_keys = ">,.,Right";
848 
849  update.bindValue(":KEYS", keylist);
850  update.bindValue(":ACTION", action);
851  update.bindValue(":HOSTNAME", hostname);
852  update.bindValue(":DEFAULT_KEYS", default_keys);
853  if (!update.exec())
854  MythDB::DBError("Unable to update keybindings",
855  update);
856 
857  keylist = ",,<";
858  action = "RWNDSTICKY";
859  default_keys = ",,<,Left";
860 
861  update.bindValue(":KEYS", keylist);
862  update.bindValue(":ACTION", action);
863  update.bindValue(":HOSTNAME", hostname);
864  update.bindValue(":DEFAULT_KEYS", default_keys);
865  if (!update.exec())
866  MythDB::DBError("Unable to update keybindings",
867  update);
868  }
869  }
870  }
871 
872  if (!UpdateDBVersionNumber("1253", dbver))
873  return false;
874  }
875 
876  if (dbver == "1253")
877  {
878  if (gCoreContext->GetNumSetting("have-nit-fix") == 1)
879  {
880  // User has previously applied patch from ticket #7486.
881  LOG(VB_GENERAL, LOG_CRIT,
882  "Upgrading to MythTV schema version 1254");
883  if (!UpdateDBVersionNumber("1254", dbver))
884  return false;
885  }
886  else
887  {
888  const char *updates[] = {
889  "ALTER TABLE videosource ADD dvb_nit_id INT(6) DEFAULT -1;",
890  nullptr
891  };
892  if (!performActualUpdate(updates, "1254", dbver))
893  return false;
894  }
895  }
896 
897  if (dbver == "1254")
898  {
899  const char *updates[] = {
900 "ALTER TABLE cardinput DROP COLUMN shareable;",
901 nullptr
902 };
903  if (!performActualUpdate(updates, "1255", dbver))
904  return false;
905  }
906 
907  if (dbver == "1255")
908  {
909  const char *updates[] = {
910 "INSERT INTO keybindings (SELECT 'Main Menu', 'EXIT', 'System Exit', "
911  "(CASE data WHEN '1' THEN 'Ctrl+Esc' WHEN '2' THEN 'Meta+Esc' "
912  "WHEN '3' THEN 'Alt+Esc' WHEN '4' THEN 'Esc' ELSE '' END), hostname "
913  "FROM settings WHERE value = 'AllowQuitShutdown' GROUP BY hostname) "
914  "ON DUPLICATE KEY UPDATE keylist = VALUES(keylist);",
915 nullptr
916 };
917  if (!performActualUpdate(updates, "1256", dbver))
918  return false;
919  }
920 
921  if (dbver == "1256")
922  {
923  const char *updates[] = {
924 "ALTER TABLE record DROP COLUMN tsdefault;",
925 nullptr
926 };
927  if (!performActualUpdate(updates, "1257", dbver))
928  return false;
929  }
930 
931  if (dbver == "1257")
932  {
933  const char *updates[] = {
934 "CREATE TABLE internetcontent "
935 "( name VARCHAR(255) NOT NULL,"
936 " thumbnail VARCHAR(255),"
937 " type SMALLINT(3) NOT NULL,"
938 " author VARCHAR(128) NOT NULL,"
939 " description TEXT NOT NULL,"
940 " commandline TEXT NOT NULL,"
941 " version DOUBLE NOT NULL,"
942 " updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"
943 " search BOOL NOT NULL,"
944 " tree BOOL NOT NULL,"
945 " podcast BOOL NOT NULL,"
946 " download BOOL NOT NULL,"
947 " host VARCHAR(128)) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
948 "CREATE TABLE internetcontentarticles "
949 "( feedtitle VARCHAR(255) NOT NULL,"
950 " path TEXT NOT NULL,"
951 " paththumb TEXT NOT NULL,"
952 " title VARCHAR(255) NOT NULL,"
953 " subtitle VARCHAR(255) NOT NULL,"
954 " season SMALLINT(5) NOT NULL DEFAULT '0',"
955 " episode SMALLINT(5) NOT NULL DEFAULT '0',"
956 " description TEXT NOT NULL,"
957 " url TEXT NOT NULL,"
958 " type SMALLINT(3) NOT NULL,"
959 " thumbnail TEXT NOT NULL,"
960 " mediaURL TEXT NOT NULL,"
961 " author VARCHAR(255) NOT NULL,"
962 " date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"
963 " time INT NOT NULL,"
964 " rating VARCHAR(255) NOT NULL,"
965 " filesize BIGINT NOT NULL,"
966 " player VARCHAR(255) NOT NULL,"
967 " playerargs TEXT NOT NULL,"
968 " download VARCHAR(255) NOT NULL,"
969 " downloadargs TEXT NOT NULL,"
970 " width SMALLINT NOT NULL,"
971 " height SMALLINT NOT NULL,"
972 " language VARCHAR(128) NOT NULL,"
973 " podcast BOOL NOT NULL,"
974 " downloadable BOOL NOT NULL,"
975 " customhtml BOOL NOT NULL,"
976 " countries VARCHAR(255) NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
977 nullptr
978 };
979  if (!performActualUpdate(updates, "1258", dbver))
980  return false;
981  }
982 
983  if (dbver == "1258")
984  {
985  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1259");
986 
987  MSqlQuery select(MSqlQuery::InitCon());
988  select.prepare("SELECT hostname, data FROM settings "
989  " WHERE value = 'IndividualMuteControl'");
990 
991  if (!select.exec())
992  {
993  MythDB::DBError("Unable to retrieve IndividualMuteControl values.",
994  select);
995  return false;
996  }
997  else
998  {
999  MSqlQuery update(MSqlQuery::InitCon());
1000  while (select.next())
1001  {
1002  QString hostname = select.value(0).toString();
1003  QString individual_mute = select.value(1).toString();
1004 
1005  if ("1" == individual_mute)
1006  {
1007  update.prepare("DELETE FROM keybindings "
1008  " WHERE action = 'CYCLEAUDIOCHAN' AND "
1009  " hostname = :HOSTNAME AND "
1010  " context IN ('TV Frontend', "
1011  " 'TV Playback')");
1012 
1013  update.bindValue(":HOSTNAME", hostname);
1014 
1015  if (!update.exec())
1016  {
1017  MythDB::DBError("Unable to update keybindings",
1018  update);
1019  return false;
1020  }
1021 
1022  update.prepare("UPDATE keybindings "
1023  " SET action = 'CYCLEAUDIOCHAN', "
1024  " description = 'Cycle audio channels'"
1025  " WHERE action = 'MUTE' AND "
1026  " hostname = :HOSTNAME AND "
1027  " context IN ('TV Frontend', "
1028  " 'TV Playback')");
1029 
1030  update.bindValue(":HOSTNAME", hostname);
1031 
1032  if (!update.exec())
1033  {
1034  MythDB::DBError("Unable to update keybindings",
1035  update);
1036  return false;
1037  }
1038 
1039  update.prepare("REPLACE INTO keybindings "
1040  " VALUES (:CONTEXT, 'MUTE', 'Mute', "
1041  " '', :HOSTNAME)");
1042 
1043  update.bindValue(":CONTEXT", "TV Playback");
1044  update.bindValue(":HOSTNAME", hostname);
1045  if (!update.exec())
1046  {
1047  MythDB::DBError("Unable to update keybindings",
1048  update);
1049  return false;
1050  }
1051  update.bindValue(":CONTEXT", "TV Frontend");
1052  update.bindValue(":HOSTNAME", hostname);
1053  if (!update.exec())
1054  {
1055  MythDB::DBError("Unable to update keybindings",
1056  update);
1057  return false;
1058  }
1059 
1060  }
1061  }
1062  }
1063 
1064  if (!UpdateDBVersionNumber("1259", dbver))
1065  return false;
1066  }
1067 
1068  if (dbver == "1259")
1069  {
1070  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1260");
1071 
1072  MSqlQuery query(MSqlQuery::InitCon());
1073  query.prepare("DELETE FROM keybindings WHERE "
1074  "action IN ('PAGEUP','PAGEDOWN') AND "
1075  "context = 'TV FRONTEND'");
1076  if (!query.exec())
1077  {
1078  MythDB::DBError("Unable to update keybindings", query);
1079  return false;
1080  }
1081 
1082  query.prepare("SELECT data FROM settings "
1083  " WHERE value = 'EPGEnableJumpToChannel'");
1084 
1085  if (!query.exec())
1086  {
1087  MythDB::DBError("Unable to retrieve EPGEnableJumpToChannel values.",
1088  query);
1089  return false;
1090  }
1091  else
1092  {
1093  MSqlQuery bindings(MSqlQuery::InitCon());
1094  while (query.next())
1095  {
1096  QString EPGEnableJumpToChannel = query.value(0).toString();
1097 
1098  if ("1" == EPGEnableJumpToChannel)
1099  {
1100  bindings.prepare("SELECT action, context, hostname, keylist "
1101  " FROM keybindings "
1102  " WHERE action IN ('DAYLEFT', "
1103  " 'DAYRIGHT', 'TOGGLEEPGORDER') AND "
1104  " context IN ('TV Frontend', "
1105  " 'TV Playback')");
1106 
1107  if (!bindings.exec())
1108  {
1109  MythDB::DBError("Unable to update keybindings",
1110  bindings);
1111  return false;
1112  }
1113  else
1114  {
1115  while (bindings.next())
1116  {
1117  QString action = bindings.value(0).toString();
1118  QString context = bindings.value(1).toString();
1119  QString hostname = bindings.value(2).toString();
1120  QStringList oldKeylist = bindings.value(3).toString().split(',');
1121  QStringList newKeyList;
1122 
1123  QStringList::iterator it;
1124  for (it = oldKeylist.begin(); it != oldKeylist.end();++it)
1125  {
1126  bool ok = false;
1127  int num = (*it).toInt(&ok);
1128  if (!ok && num >= 0 && num <= 9)
1129  newKeyList << (*it);
1130  }
1131  QString keyList = newKeyList.join(",");
1132 
1133  MSqlQuery update(MSqlQuery::InitCon());
1134  update.prepare("UPDATE keybindings "
1135  " SET keylist = :KEYLIST "
1136  " WHERE action = :ACTION "
1137  " AND context = :CONTEXT "
1138  " AND hostname = :HOSTNAME");
1139 
1140  update.bindValue(":KEYLIST", keyList);
1141  update.bindValue(":ACTION", action);
1142  update.bindValue(":CONTEXT", context);
1143  update.bindValue(":HOSTNAME", hostname);
1144 
1145  if (!update.exec())
1146  {
1147  MythDB::DBError("Unable to update keybindings",
1148  update);
1149  return false;
1150  }
1151  }
1152  }
1153 
1154  }
1155  }
1156  }
1157 
1158  if (!UpdateDBVersionNumber("1260", dbver))
1159  return false;
1160  }
1161 
1162  if (dbver == "1260")
1163  {
1164  if (gCoreContext->GetBoolSetting("MythFillFixProgramIDsHasRunOnce", false))
1165  {
1166  LOG(VB_GENERAL, LOG_CRIT,
1167  "Upgrading to MythTV schema version 1261");
1168  if (!UpdateDBVersionNumber("1261", dbver))
1169  return false;
1170  }
1171  else
1172  {
1173 
1174  const char *updates[] = {
1175 "UPDATE recorded SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
1176 " SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
1177 "UPDATE oldrecorded SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
1178 " SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
1179 "UPDATE program SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
1180 " SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
1181 nullptr
1182 };
1183  if (!performActualUpdate(updates, "1261", dbver))
1184  return false;
1185  }
1186  }
1187 
1188  if (dbver == "1261")
1189  {
1190  const char *updates[] = {
1191 "UPDATE program SET description = '' WHERE description IS NULL;",
1192 "UPDATE record SET description = '' WHERE description IS NULL;",
1193 "UPDATE recorded SET description = '' WHERE description IS NULL;",
1194 "UPDATE recordedprogram SET description = '' WHERE description IS NULL;",
1195 "UPDATE oldrecorded SET description = '' WHERE description IS NULL;",
1196 "UPDATE mythlog SET details = '' WHERE details IS NULL;",
1197 "UPDATE settings SET data = '' WHERE data IS NULL;",
1198 "UPDATE powerpriority SET selectclause = '' WHERE selectclause IS NULL;",
1199 "UPDATE customexample SET fromclause = '' WHERE fromclause IS NULL;",
1200 "UPDATE customexample SET whereclause = '' WHERE whereclause IS NULL;",
1201 "ALTER TABLE program MODIFY COLUMN description VARCHAR(16000) "
1202 " NOT NULL default '';",
1203 "ALTER TABLE record MODIFY COLUMN description VARCHAR(16000) "
1204 " NOT NULL default '';",
1205 "ALTER TABLE recorded MODIFY COLUMN description VARCHAR(16000) "
1206 " NOT NULL default '';",
1207 "ALTER TABLE recordedprogram MODIFY COLUMN description VARCHAR(16000) "
1208 " NOT NULL default '';",
1209 "ALTER TABLE oldrecorded MODIFY COLUMN description VARCHAR(16000) "
1210 " NOT NULL default '';",
1211 "ALTER TABLE mythlog MODIFY COLUMN details VARCHAR(16000) "
1212 " NOT NULL default '';",
1213 "ALTER TABLE settings MODIFY COLUMN data VARCHAR(16000) "
1214 " NOT NULL default '';",
1215 "ALTER TABLE powerpriority MODIFY COLUMN selectclause VARCHAR(16000) "
1216 " NOT NULL default '';",
1217 "ALTER TABLE customexample MODIFY COLUMN fromclause VARCHAR(10000) "
1218 " NOT NULL default '';",
1219 "ALTER TABLE customexample MODIFY COLUMN whereclause VARCHAR(10000) "
1220 " NOT NULL default '';",
1221 nullptr
1222 };
1223  if (!performActualUpdate(updates, "1262", dbver))
1224  return false;
1225  }
1226 
1227  if (dbver == "1262")
1228  {
1229  const char *updates[] = {
1230 "INSERT INTO recgrouppassword (recgroup, password) SELECT 'All Programs',data FROM settings WHERE value='AllRecGroupPassword' LIMIT 1;",
1231 "DELETE FROM settings WHERE value='AllRecGroupPassword';",
1232 nullptr
1233 };
1234  if (!performActualUpdate(updates, "1263", dbver))
1235  return false;
1236  }
1237 
1238  if (dbver == "1263")
1239  {
1240  const char *updates[] = {
1241 "UPDATE settings SET hostname = NULL WHERE value='ISO639Language0' AND data != 'aar' AND hostname IS NOT NULL LIMIT 1;",
1242 "UPDATE settings SET hostname = NULL WHERE value='ISO639Language1' AND data != 'aar' AND hostname IS NOT NULL LIMIT 1;",
1243 "DELETE FROM settings WHERE value='ISO639Language0' AND hostname IS NOT NULL;",
1244 "DELETE FROM settings WHERE value='ISO639Language1' AND hostname IS NOT NULL;",
1245 nullptr
1246 };
1247  if (!performActualUpdate(updates, "1264", dbver))
1248  return false;
1249  }
1250 
1251  if (dbver == "1264")
1252  {
1253  const char *updates[] = {
1254 "DELETE FROM displayprofiles WHERE profilegroupid IN "
1255 " (SELECT profilegroupid FROM displayprofilegroups "
1256 " WHERE name IN ('CPU++', 'CPU+', 'CPU--'))",
1257 "DELETE FROM displayprofilegroups WHERE name IN ('CPU++', 'CPU+', 'CPU--')",
1258 "DELETE FROM settings WHERE value = 'DefaultVideoPlaybackProfile' "
1259 " AND data IN ('CPU++', 'CPU+', 'CPU--')",
1260 "UPDATE displayprofiles SET data = 'ffmpeg' WHERE data = 'libmpeg2'",
1261 "UPDATE displayprofiles SET data = 'ffmpeg' WHERE data = 'xvmc'",
1262 "UPDATE displayprofiles SET data = 'xv-blit' WHERE data = 'xvmc-blit'",
1263 "UPDATE displayprofiles SET data = 'softblend' WHERE data = 'ia44blend'",
1264 nullptr
1265 };
1266  if (!performActualUpdate(updates, "1265", dbver))
1267  return false;
1268  }
1269 
1270  if (dbver == "1265")
1271  {
1272  const char *updates[] = {
1273 "ALTER TABLE dtv_multiplex MODIFY COLUMN updatetimestamp "
1274 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;",
1275 "ALTER TABLE dvdbookmark MODIFY COLUMN `timestamp` "
1276 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;",
1277 "ALTER TABLE jobqueue MODIFY COLUMN statustime "
1278 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;",
1279 "ALTER TABLE recorded MODIFY COLUMN lastmodified "
1280 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;",
1281 nullptr
1282 };
1283  if (!performActualUpdate(updates, "1266", dbver))
1284  return false;
1285  }
1286 
1287  if (dbver == "1266")
1288  {
1290  return false;
1291 
1292  const char *updates[] = {
1293 "DELETE FROM settings WHERE value = 'mythvideo.DBSchemaVer'",
1294 nullptr
1295 };
1296  if (!performActualUpdate(updates, "1267", dbver))
1297  return false;
1298  }
1299 
1300  if (dbver == "1267")
1301  {
1302  const char *updates[] = {
1303 "ALTER TABLE channel MODIFY xmltvid VARCHAR(255) NOT NULL DEFAULT '';",
1304 nullptr
1305 };
1306  if (!performActualUpdate(updates, "1268", dbver))
1307  return false;
1308  }
1309 
1310  if (dbver == "1268")
1311  {
1312 
1313  const char *updates[] = {
1314 "DELETE FROM keybindings WHERE action='PREVSOURCE' AND keylist='Ctrl+Y';",
1315 nullptr
1316 };
1317  if (!performActualUpdate(updates, "1269", dbver))
1318  return false;
1319  }
1320 
1321  if (dbver == "1269")
1322  {
1323  const char *updates[] = {
1324 "DELETE FROM profilegroups WHERE id >= 15;",
1325 "DELETE FROM recordingprofiles WHERE profilegroup >= 15;",
1326 "INSERT INTO profilegroups SET id = '15', name = 'ASI Recorder (DVEO)',"
1327 " cardtype = 'ASI', is_default = 1;",
1328 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 15;",
1329 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 15;",
1330 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 15;",
1331 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 15;",
1332 "INSERT INTO profilegroups SET id = '16', name = 'OCUR Recorder (CableLabs)',"
1333 " cardtype = 'OCUR', is_default = 1;",
1334 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 16;",
1335 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 16;",
1336 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 16;",
1337 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 16;",
1338 nullptr
1339 };
1340  if (!performActualUpdate(updates, "1270", dbver))
1341  return false;
1342  }
1343 
1344  if (dbver == "1270")
1345  {
1346  const char *updates[] = {
1347 "ALTER TABLE oldrecorded ADD future TINYINT(1) NOT NULL DEFAULT 0;",
1348 "UPDATE oldrecorded SET future=0;",
1349 nullptr
1350 };
1351  if (!performActualUpdate(updates, "1271", dbver))
1352  return false;
1353  }
1354 
1355  if (dbver == "1271")
1356  {
1357  const char *updates[] = {
1358 "ALTER TABLE recordmatch MODIFY recordid INT UNSIGNED NOT NULL;",
1359 "ALTER TABLE recordmatch MODIFY chanid INT UNSIGNED NOT NULL;",
1360 "ALTER TABLE recordmatch MODIFY starttime DATETIME NOT NULL;",
1361 "ALTER TABLE recordmatch MODIFY manualid INT UNSIGNED NOT NULL;",
1362 "ALTER TABLE recordmatch ADD INDEX (starttime, chanid);",
1363 "ALTER TABLE oldrecorded MODIFY generic TINYINT(1) NOT NULL;",
1364 "ALTER TABLE oldrecorded ADD INDEX (future);",
1365 "ALTER TABLE oldrecorded ADD INDEX (starttime, chanid);",
1366 nullptr
1367 };
1368  if (!performActualUpdate(updates, "1272", dbver))
1369  return false;
1370  }
1371 
1372  if (dbver == "1272")
1373  {
1374  const char *updates[] = {
1375 "DROP INDEX starttime ON recordmatch;",
1376 "DROP INDEX starttime ON oldrecorded;",
1377 "ALTER TABLE recordmatch ADD INDEX (chanid, starttime, manualid);",
1378 "ALTER TABLE oldrecorded ADD INDEX (chanid, starttime);",
1379 nullptr
1380 };
1381  if (!performActualUpdate(updates, "1273", dbver))
1382  return false;
1383  }
1384 
1385  if (dbver == "1273")
1386  {
1387  const char *updates[] = {
1388 "ALTER TABLE internetcontent MODIFY COLUMN updated "
1389 " DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';",
1390 "ALTER TABLE internetcontentarticles MODIFY COLUMN `date` "
1391 " DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';",
1392 nullptr
1393 };
1394 
1395  if (!performActualUpdate(updates, "1274", dbver))
1396  return false;
1397  }
1398 
1399  if (dbver == "1274")
1400  {
1401  const char *updates[] = {
1402 "UPDATE cardinput SET tunechan=NULL"
1403 " WHERE inputname='DVBInput' OR inputname='MPEG2TS';"
1404 "UPDATE dtv_multiplex SET symbolrate = NULL"
1405 " WHERE modulation LIKE 't%' OR modulation LIKE '%t';",
1406 "UPDATE dtv_multiplex"
1407 " SET bandwidth=SUBSTR(modulation,2,1)"
1408 " WHERE SUBSTR(modulation,3,3)='qam' OR"
1409 " SUBSTR(modulation,3,4)='qpsk';",
1410 "UPDATE dtv_multiplex"
1411 " SET bandwidth=SUBSTR(modulation,5,1)"
1412 " WHERE SUBSTR(modulation,1,4)='auto' AND"
1413 " LENGTH(modulation)=6;",
1414 "UPDATE dtv_multiplex SET modulation='auto'"
1415 " WHERE modulation LIKE 'auto%';",
1416 "UPDATE dtv_multiplex SET modulation='qam_16'"
1417 " WHERE modulation LIKE '%qam16%';",
1418 "UPDATE dtv_multiplex SET modulation='qam_32'"
1419 " WHERE modulation LIKE '%qam32%';",
1420 "UPDATE dtv_multiplex SET modulation='qam_64'"
1421 " WHERE modulation LIKE '%qam64%';",
1422 "UPDATE dtv_multiplex SET modulation='qam_128'"
1423 " WHERE modulation LIKE '%qam128%';",
1424 "UPDATE dtv_multiplex SET modulation='qam_256'"
1425 " WHERE modulation LIKE '%qam256%';",
1426 nullptr
1427 };
1428  if (!performActualUpdate(updates, "1275", dbver))
1429  return false;
1430  }
1431 
1432  if (dbver == "1275")
1433  {
1434  const char *updates[] = {
1435 "DROP TABLE IF EXISTS `logging`;",
1436 "CREATE TABLE `logging` ( "
1437 " `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, "
1438 " `host` varchar(64) NOT NULL, "
1439 " `application` varchar(64) NOT NULL, "
1440 " `pid` int(11) NOT NULL, "
1441 " `thread` varchar(64) NOT NULL, "
1442 " `msgtime` datetime NOT NULL, "
1443 " `level` int(11) NOT NULL, "
1444 " `message` varchar(2048) NOT NULL, "
1445 " PRIMARY KEY (`id`), "
1446 " KEY `host` (`host`,`application`,`pid`,`msgtime`), "
1447 " KEY `msgtime` (`msgtime`), "
1448 " KEY `level` (`level`) "
1449 ") ENGINE=MyISAM DEFAULT CHARSET=utf8; ",
1450 nullptr
1451 };
1452  if (!performActualUpdate(updates, "1276", dbver))
1453  return false;
1454  }
1455 
1456  if (dbver == "1276")
1457  {
1458  const char *updates[] = {
1459 "ALTER TABLE record ADD COLUMN filter INT UNSIGNED NOT NULL DEFAULT 0;",
1460 "CREATE TABLE IF NOT EXISTS recordfilter ("
1461 " filterid INT UNSIGNED NOT NULL PRIMARY KEY,"
1462 " description VARCHAR(64) DEFAULT NULL,"
1463 " clause VARCHAR(256) DEFAULT NULL,"
1464 " newruledefault TINYINT(1) DEFAULT 0) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
1465 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1466 " VALUES (0, 'New episode', 'program.previouslyshown = 0', 0);",
1467 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1468 " VALUES (1, 'Identifiable episode', 'program.generic = 0', 0);",
1469 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1470 " VALUES (2, 'First showing', 'program.first > 0', 0);",
1471 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1472 " VALUES (3, 'Primetime', 'HOUR(program.starttime) >= 19 AND HOUR(program.starttime) < 23', 0);",
1473 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1474 " VALUES (4, 'Commercial free', 'channel.commmethod = -2', 0);",
1475 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1476 " VALUES (5, 'High definition', 'program.hdtv > 0', 0);",
1477 nullptr
1478 };
1479 
1480  if (!performActualUpdate(updates, "1277", dbver))
1481  return false;
1482  }
1483 
1484  if (dbver == "1277")
1485  {
1486  const char *updates[] = {
1487 "ALTER TABLE record ADD autometadata TINYINT(1) NOT NULL DEFAULT "
1488 " 0 AFTER autouserjob4;",
1489 "ALTER TABLE record ADD inetref VARCHAR(40) NOT NULL AFTER programid;",
1490 "ALTER TABLE record ADD season SMALLINT(5) NOT NULL AFTER description;",
1491 "ALTER TABLE record ADD episode SMALLINT(5) NOT NULL AFTER season;",
1492 "ALTER TABLE recorded ADD inetref VARCHAR(40) NOT NULL AFTER programid;",
1493 "ALTER TABLE recorded ADD season SMALLINT(5) NOT NULL AFTER description;",
1494 "ALTER TABLE recorded ADD episode SMALLINT(5) NOT NULL AFTER season;",
1495 "ALTER TABLE oldrecorded ADD inetref VARCHAR(40) NOT NULL AFTER programid;",
1496 "ALTER TABLE oldrecorded ADD season SMALLINT(5) NOT NULL AFTER description;",
1497 "ALTER TABLE oldrecorded ADD episode SMALLINT(5) NOT NULL AFTER season;",
1498 nullptr
1499 };
1500  if (!performActualUpdate(updates, "1278", dbver))
1501  return false;
1502  }
1503 
1504  if (dbver == "1278")
1505  {
1506  const char *updates[] = {
1507 "CREATE TABLE recordedartwork ( "
1508 " inetref VARCHAR(255) NOT NULL, "
1509 " season SMALLINT(5) NOT NULL, "
1510 " host TEXT NOT NULL, "
1511 " coverart TEXT NOT NULL, "
1512 " fanart TEXT NOT NULL, "
1513 " banner TEXT NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
1514 nullptr
1515 };
1516  if (!performActualUpdate(updates, "1279", dbver))
1517  return false;
1518  }
1519 
1520  if (dbver == "1279")
1521  {
1522  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1280");
1523 
1524  MSqlQuery select(MSqlQuery::InitCon());
1525  // New DBs/hosts will not have a NoPromptOnExit, so they'll get defaults
1526  select.prepare("SELECT hostname, data FROM settings "
1527  " WHERE value = 'NoPromptOnExit'");
1528  if (!select.exec())
1529  {
1530  MythDB::DBError("Unable to retrieve confirm exit values.", select);
1531  }
1532  else
1533  {
1534  MSqlQuery update(MSqlQuery::InitCon());
1535  while (select.next())
1536  {
1537  QString hostname = select.value(0).toString();
1538  // Yes, enabled NoPromptOnExit meant to prompt on exit
1539  QString prompt_on_exit = select.value(1).toString();
1540  // Default EXITPROMPT is wrong for all upgrades
1541  update.prepare("DELETE FROM keybindings "
1542  " WHERE action = 'EXITPROMPT' "
1543  " AND context = 'Main Menu' "
1544  " AND hostname = :HOSTNAME ;");
1545  update.bindValue(":HOSTNAME", hostname);
1546  if (!update.exec())
1547  MythDB::DBError("Unable to delete EXITPROMPT binding",
1548  update);
1549 
1550  if ("0" == prompt_on_exit)
1551  {
1552  // EXIT is already mapped appropriately, so just create a
1553  // no-keylist mapping for EXITPROMPT to prevent conflict
1554  update.prepare("INSERT INTO keybindings (context, action, "
1555  " description, keylist, hostname) "
1556  "VALUES ('Main Menu', 'EXITPROMPT', '', "
1557  " '', :HOSTNAME );");
1558  update.bindValue(":HOSTNAME", hostname);
1559  if (!update.exec())
1560  MythDB::DBError("Unable to create EXITPROMPT binding",
1561  update);
1562  }
1563  else
1564  {
1565  // EXIT must be changed to EXITPROMPT
1566  update.prepare("UPDATE keybindings "
1567  " SET action = 'EXITPROMPT' "
1568  " WHERE action = 'EXIT' "
1569  " AND context = 'Main Menu' "
1570  " AND hostname = :HOSTNAME ;");
1571  update.bindValue(":HOSTNAME", hostname);
1572  if (!update.exec())
1573  MythDB::DBError("Unable to update EXITPROMPT binding",
1574  update);
1575  }
1576  }
1577  }
1578 
1579  if (!UpdateDBVersionNumber("1280", dbver))
1580  return false;
1581  }
1582 
1583  if (dbver == "1280")
1584  {
1585  const char *updates[] = {
1586 "ALTER TABLE program ADD INDEX (subtitle);",
1587 "ALTER TABLE program ADD INDEX (description(255));",
1588 "ALTER TABLE oldrecorded ADD INDEX (subtitle);",
1589 "ALTER TABLE oldrecorded ADD INDEX (description(255));",
1590 nullptr
1591 };
1592  if (!performActualUpdate(updates, "1281", dbver))
1593  return false;
1594  }
1595 
1596  if (dbver == "1281")
1597  {
1598  const char *updates[] = {
1599 "ALTER TABLE cardinput ADD changer_device VARCHAR(128) "
1600 "AFTER externalcommand;",
1601 "ALTER TABLE cardinput ADD changer_model VARCHAR(128) "
1602 "AFTER changer_device;",
1603 nullptr
1604 };
1605  if (!performActualUpdate(updates, "1282", dbver))
1606  return false;
1607  }
1608 
1609  if (dbver == "1282")
1610  {
1611  const char *updates[] = {
1612 "UPDATE settings"
1613 " SET data = SUBSTR(data, INSTR(data, 'share/mythtv/metadata')+13)"
1614 " WHERE value "
1615 " IN ('TelevisionGrabber', "
1616 " 'MovieGrabber', "
1617 " 'mythgame.MetadataGrabber');",
1618 nullptr
1619 };
1620 
1621  if (!performActualUpdate(updates, "1283", dbver))
1622  return false;
1623  }
1624 
1625  if (dbver == "1283")
1626  {
1627  const char *updates[] = {
1628 "UPDATE record SET filter = filter | 1 WHERE record.dupin & 0x20",
1629 "UPDATE record SET filter = filter | 2 WHERE record.dupin & 0x40",
1630 "UPDATE record SET filter = filter | 5 WHERE record.dupin & 0x80",
1631 "UPDATE record SET dupin = dupin & ~0xe0",
1632 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1633 " VALUES (6, 'This Episode', '(program.programid <> '''' AND program.programid = RECTABLE.programid) OR (program.programid = '''' AND program.subtitle = RECTABLE.subtitle AND program.description = RECTABLE.description)', 0);",
1634 nullptr
1635 };
1636 
1637  if (!performActualUpdate(updates, "1284", dbver))
1638  return false;
1639  }
1640 
1641  if (dbver == "1284")
1642  {
1643  const char *updates[] = {
1644 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
1645 " VALUES (6, 'This Episode', '(RECTABLE.programid <> '''' AND program.programid = RECTABLE.programid) OR (RECTABLE.programid = '''' AND program.subtitle = RECTABLE.subtitle AND program.description = RECTABLE.description)', 0);",
1646 nullptr
1647 };
1648 
1649  if (!performActualUpdate(updates, "1285", dbver))
1650  return false;
1651  }
1652 
1653  if (dbver == "1285")
1654  {
1655  const char *updates[] = {
1656 "DELETE FROM profilegroups WHERE id >= 17;",
1657 "DELETE FROM recordingprofiles WHERE profilegroup >= 17;",
1658 "INSERT INTO profilegroups SET id = '17', name = 'Ceton Recorder',"
1659 " cardtype = 'CETON', is_default = 1;",
1660 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 17;",
1661 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 17;",
1662 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 17;",
1663 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 17;",
1664 nullptr
1665 };
1666  if (!performActualUpdate(updates, "1286", dbver))
1667  return false;
1668  }
1669 
1670  if (dbver == "1286")
1671  {
1672  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1287");
1673  MSqlQuery query(MSqlQuery::InitCon());
1674  query.prepare("SELECT cardid, videodevice "
1675  "FROM capturecard "
1676  "WHERE cardtype='CETON'");
1677  if (!query.exec())
1678  {
1679  LOG(VB_GENERAL, LOG_ERR,
1680  "Unable to query capturecard table for upgrade to 1287.");
1681  return false;
1682  }
1683 
1684  MSqlQuery update(MSqlQuery::InitCon());
1685  update.prepare("UPDATE capturecard SET videodevice=:VIDDEV "
1686  "WHERE cardid=:CARDID");
1687  while (query.next())
1688  {
1689  uint cardid = query.value(0).toUInt();
1690  QString videodevice = query.value(1).toString();
1691  QStringList parts = videodevice.split("-");
1692  if (parts.size() != 2)
1693  {
1694  LOG(VB_GENERAL, LOG_ERR,
1695  "Unable to parse videodevice in upgrade to 1287.");
1696  return false;
1697  }
1698  if (parts[1].contains("."))
1699  continue; // already in new format, skip it..
1700 
1701  int input = max(parts[1].toInt() - 1, 0);
1702  videodevice = parts[0] + QString("-0.%1").arg(input);
1703  update.bindValue(":CARDID", cardid);
1704  update.bindValue(":VIDDEV", videodevice);
1705  if (!update.exec())
1706  {
1707  LOG(VB_GENERAL, LOG_ERR,
1708  "Failed to update videodevice in upgrade to 1287.");
1709  return false;
1710  }
1711  }
1712 
1713  if (!UpdateDBVersionNumber("1287", dbver))
1714  return false;
1715  }
1716 
1717  if (dbver == "1287")
1718  {
1719  const char *updates[] = {
1720 "CREATE TABLE IF NOT EXISTS livestream ( "
1721 " id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, "
1722 " width INT UNSIGNED NOT NULL, "
1723 " height INT UNSIGNED NOT NULL, "
1724 " bitrate INT UNSIGNED NOT NULL, "
1725 " audiobitrate INT UNSIGNED NOT NULL, "
1726 " samplerate INT UNSIGNED NOT NULL, "
1727 " audioonlybitrate INT UNSIGNED NOT NULL, "
1728 " segmentsize INT UNSIGNED NOT NULL DEFAULT 10, "
1729 " maxsegments INT UNSIGNED NOT NULL DEFAULT 0, "
1730 " startsegment INT UNSIGNED NOT NULL DEFAULT 0, "
1731 " currentsegment INT UNSIGNED NOT NULL DEFAULT 0, "
1732 " segmentcount INT UNSIGNED NOT NULL DEFAULT 0, "
1733 " percentcomplete INT UNSIGNED NOT NULL DEFAULT 0, "
1734 " created DATETIME NOT NULL, "
1735 " lastmodified DATETIME NOT NULL, "
1736 " relativeurl VARCHAR(512) NOT NULL, "
1737 " fullurl VARCHAR(1024) NOT NULL, "
1738 " status INT UNSIGNED NOT NULL DEFAULT 0, "
1739 " statusmessage VARCHAR(256) NOT NULL, "
1740 " sourcefile VARCHAR(512) NOT NULL, "
1741 " sourcehost VARCHAR(64) NOT NULL, "
1742 " sourcewidth INT UNSIGNED NOT NULL DEFAULT 0, "
1743 " sourceheight INT UNSIGNED NOT NULL DEFAULT 0, "
1744 " outdir VARCHAR(256) NOT NULL, "
1745 " outbase VARCHAR(128) NOT NULL "
1746 ") ENGINE=MyISAM DEFAULT CHARSET=utf8; ",
1747 nullptr
1748 };
1749 
1750  if (!performActualUpdate(updates, "1288", dbver))
1751  return false;
1752  }
1753 
1754  if (dbver == "1288")
1755  {
1756  const char *updates[] = {
1757 "ALTER TABLE recordedprogram CHANGE COLUMN videoprop videoprop "
1758 " SET('HDTV', 'WIDESCREEN', 'AVC', '720', '1080', 'DAMAGED') NOT NULL; ",
1759 nullptr
1760 };
1761  if (!performActualUpdate(updates, "1289", dbver))
1762  return false;
1763  }
1764 
1765  if (dbver == "1289")
1766  {
1767  const char *updates[] = {
1768 "DROP TABLE IF EXISTS netvisionrssitems;",
1769 "DROP TABLE IF EXISTS netvisionsearchgrabbers;",
1770 "DROP TABLE IF EXISTS netvisionsites;",
1771 "DROP TABLE IF EXISTS netvisiontreegrabbers;",
1772 "DROP TABLE IF EXISTS netvisiontreeitems;",
1773 nullptr
1774 };
1775 
1776  if (!performActualUpdate(updates, "1290", dbver))
1777  return false;
1778  }
1779 
1780  if (dbver == "1290")
1781  {
1782  const char *updates[] = {
1783 "ALTER TABLE logging "
1784 " ALTER COLUMN host SET DEFAULT '', "
1785 " ALTER COLUMN application SET DEFAULT '', "
1786 " ALTER COLUMN pid SET DEFAULT '0', "
1787 " ALTER COLUMN thread SET DEFAULT '', "
1788 " ALTER COLUMN level SET DEFAULT '0';",
1789 "ALTER TABLE logging "
1790 " ADD COLUMN tid INT(11) NOT NULL DEFAULT '0' AFTER pid, "
1791 " ADD COLUMN filename VARCHAR(255) NOT NULL DEFAULT '' AFTER thread, "
1792 " ADD COLUMN line INT(11) NOT NULL DEFAULT '0' AFTER filename, "
1793 " ADD COLUMN function VARCHAR(255) NOT NULL DEFAULT '' AFTER line;",
1794 nullptr
1795 };
1796 
1797  if (!performActualUpdate(updates, "1291", dbver))
1798  return false;
1799  }
1800 
1801  if (dbver == "1291")
1802  {
1803  const char *updates[] = {
1804 "UPDATE recorded r, recordedprogram rp SET r.duplicate=0 "
1805 " WHERE r.chanid=rp.chanid AND r.progstart=rp.starttime AND "
1806 " FIND_IN_SET('DAMAGED', rp.videoprop);",
1807 nullptr
1808 };
1809 
1810  if (!performActualUpdate(updates, "1292", dbver))
1811  return false;
1812  }
1813 
1814  if (dbver == "1292")
1815  {
1816  const char *updates[] = {
1817 "ALTER TABLE cardinput "
1818 " ADD COLUMN schedorder INT(10) UNSIGNED NOT NULL DEFAULT '0', "
1819 " ADD COLUMN livetvorder INT(10) UNSIGNED NOT NULL DEFAULT '0';",
1820 "UPDATE cardinput SET schedorder = cardinputid;",
1821 "UPDATE cardinput SET livetvorder = cardid;",
1822 nullptr
1823 };
1824 
1825  if (gCoreContext->GetBoolSetting("LastFreeCard", false))
1826  {
1827  updates[2] =
1828  "UPDATE cardinput SET livetvorder = "
1829  " (SELECT MAX(cardid) FROM capturecard) - cardid + 1;";
1830  }
1831 
1832  if (!performActualUpdate(updates, "1293", dbver))
1833  return false;
1834  }
1835 
1836  if (dbver == "1293")
1837  {
1838  const char *updates[] = {
1839 "TRUNCATE TABLE recordmatch",
1840 "ALTER TABLE recordmatch DROP INDEX recordid",
1841 "ALTER TABLE recordmatch ADD UNIQUE INDEX (recordid, chanid, starttime)",
1842 "UPDATE recordfilter SET description='Prime time' WHERE filterid=3",
1843 "UPDATE recordfilter SET description='This episode' WHERE filterid=6",
1844 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
1845 " VALUES (7, 'This series', '(RECTABLE.seriesid <> '''' AND program.seriesid = RECTABLE.seriesid)', 0);",
1846 nullptr
1847 };
1848 
1849  if (!performActualUpdate(updates, "1294", dbver))
1850  return false;
1851  }
1852 
1853  if (dbver == "1294")
1854  {
1855  const char *updates[] = {
1856 "CREATE TABLE videocollection ("
1857 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
1858 " title varchar(256) NOT NULL,"
1859 " contenttype set('MOVIE', 'TELEVISION', 'ADULT', 'MUSICVIDEO', 'HOMEVIDEO') NOT NULL default '',"
1860 " plot text,"
1861 " network varchar(128) DEFAULT NULL,"
1862 " inetref varchar(128) NOT NULL,"
1863 " certification varchar(128) DEFAULT NULL,"
1864 " genre int(10) unsigned DEFAULT '0',"
1865 " releasedate date DEFAULT NULL,"
1866 " language varchar(10) DEFAULT NULL,"
1867 " status varchar(64) DEFAULT NULL,"
1868 " rating float DEFAULT 0,"
1869 " ratingcount int(10) DEFAULT 0,"
1870 " runtime smallint(5) unsigned DEFAULT '0',"
1871 " banner text,"
1872 " fanart text,"
1873 " coverart text,"
1874 " PRIMARY KEY (intid),"
1875 " KEY title (title)"
1876 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
1877 "CREATE TABLE videopathinfo ("
1878 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
1879 " path text,"
1880 " contenttype set('MOVIE', 'TELEVISION', 'ADULT', 'MUSICVIDEO', 'HOMEVIDEO') NOT NULL default '',"
1881 " collectionref int(10) default '0',"
1882 " recurse tinyint(1) default '0',"
1883 " PRIMARY KEY (intid)"
1884 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
1885 "ALTER TABLE videometadata ADD collectionref int(10) NOT NULL DEFAULT '0' AFTER inetref;",
1886 "ALTER TABLE videometadata ADD playcount int(10) NOT NULL DEFAULT '0' AFTER length;",
1887 "ALTER TABLE videometadata ADD contenttype set('MOVIE', 'TELEVISION', 'ADULT', 'MUSICVIDEO', 'HOMEVIDEO') NOT NULL default ''",
1888 "UPDATE videometadata SET contenttype = 'MOVIE';",
1889 "UPDATE videometadata SET contenttype = 'TELEVISION' WHERE season > 0 OR episode > 0;",
1890 nullptr
1891 };
1892 
1893  if (!performActualUpdate(updates, "1295", dbver))
1894  return false;
1895  }
1896 
1897  if (dbver == "1295")
1898  {
1899  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1296");
1900  MSqlQuery query(MSqlQuery::InitCon());
1901  query.prepare("SELECT data, hostname "
1902  "FROM settings "
1903  "WHERE value='BackendServerIP'");
1904  if (!query.exec())
1905  {
1906  LOG(VB_GENERAL, LOG_ERR,
1907  "Unable to repair IP addresses for IPv4/IPv6 split.");
1908  return false;
1909  }
1910 
1911  MSqlQuery update(MSqlQuery::InitCon()), insert(MSqlQuery::InitCon());
1912  update.prepare("UPDATE settings "
1913  "SET data=:IP4ADDY "
1914  "WHERE value='BackendServerIP' "
1915  "AND hostname=:HOSTNAME");
1916  insert.prepare("INSERT INTO settings "
1917  "SET value='BackendServerIP6',"
1918  "data=:IP6ADDY,"
1919  "hostname=:HOSTNAME");
1920  while (query.next())
1921  {
1922  QHostAddress oldaddr(query.value(0).toString());
1923  QString hostname = query.value(1).toString();
1924 
1925  update.bindValue(":HOSTNAME", hostname);
1926  insert.bindValue(":HOSTNAME", hostname);
1927 
1928  if (oldaddr.protocol() == QAbstractSocket::IPv6Protocol)
1929  {
1930  update.bindValue(":IP4ADDY", "127.0.0.1");
1931  insert.bindValue(":IP6ADDY", query.value(0).toString());
1932  }
1933  else if (oldaddr.protocol() == QAbstractSocket::IPv4Protocol)
1934  {
1935  update.bindValue(":IP4ADDY", query.value(0).toString());
1936  insert.bindValue(":IP6ADDY", "::1");
1937  }
1938  else
1939  {
1940  update.bindValue(":IP4ADDY", "127.0.0.1");
1941  insert.bindValue(":IP6ADDY", "::1");
1942  LOG(VB_GENERAL, LOG_CRIT,
1943  QString("Invalid address string '%1' found on %2. "
1944  "Reverting to localhost defaults.")
1945  .arg(query.value(0).toString()).arg(hostname));
1946  }
1947 
1948  if (!update.exec() || !insert.exec())
1949  {
1950  LOG(VB_GENERAL, LOG_ERR, QString("Failed to separate IPv4 "
1951  "and IPv6 addresses for %1").arg(hostname));
1952  return false;
1953  }
1954 
1955  }
1956 
1957  if (!UpdateDBVersionNumber("1296", dbver))
1958  return false;
1959  }
1960 
1961  if (dbver == "1296")
1962  {
1963  const char *updates[] = {
1964 "ALTER TABLE videocollection CHANGE inetref collectionref "
1965 "VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci "
1966 "NOT NULL",
1967 "ALTER TABLE videocollection CHANGE genre genre VARCHAR(128) NULL DEFAULT ''",
1968 nullptr
1969 };
1970 
1971  if (!performActualUpdate(updates, "1297", dbver))
1972  return false;
1973  }
1974 
1975  if (dbver == "1297")
1976  {
1977  const char *updates[] = {
1978 "ALTER TABLE videometadata CHANGE collectionref collectionref INT(10) "
1979 "NOT NULL DEFAULT -1",
1980 "UPDATE videometadata SET collectionref = '-1'",
1981 nullptr
1982 };
1983 
1984  if (!performActualUpdate(updates, "1298", dbver))
1985  return false;
1986  }
1987 
1988  if (dbver == "1298")
1989  {
1990  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1299");
1991 
1992  // DeletedMaxAge setting only exists if the user ever triggered the
1993  // DeletedExpireOptions TriggeredConfigurationGroup (enabled
1994  // AutoExpireInsteadOfDelete) and changed DeletedMaxAge from its
1995  // default of zero, so "reset" it to ensure it's in the database before
1996  // the update
1997  QString deletedMaxAge = gCoreContext->GetSetting("DeletedMaxAge", "0");
1998  gCoreContext->SaveSettingOnHost("DeletedMaxAge", deletedMaxAge, nullptr);
1999 
2000  QString queryStr;
2001  if (gCoreContext->GetBoolSetting("AutoExpireInsteadOfDelete", false))
2002  {
2003  queryStr = "UPDATE settings SET data='-1' WHERE "
2004  "value='DeletedMaxAge' AND data='0'";
2005  }
2006  else
2007  {
2008  queryStr = "UPDATE settings SET data='0' WHERE "
2009  "value='DeletedMaxAge'";
2010  }
2011 
2012  MSqlQuery query(MSqlQuery::InitCon());
2013  query.prepare(queryStr);
2014  if (!query.exec())
2015  {
2016  MythDB::DBError("Could not perform update for '1299'", query);
2017  return false;
2018  }
2019 
2020  if (!UpdateDBVersionNumber("1299", dbver))
2021  return false;
2022  }
2023 
2024  if (dbver == "1299")
2025  {
2026  const char *updates[] = {
2027 "ALTER TABLE recordmatch ADD COLUMN findid INT NOT NULL DEFAULT 0",
2028 "ALTER TABLE recordmatch ADD INDEX (recordid, findid)",
2029 nullptr
2030 };
2031 
2032  if (!performActualUpdate(updates, "1300", dbver))
2033  return false;
2034  }
2035 
2036  if (dbver == "1300")
2037  {
2038  const char *updates[] = {
2039 "ALTER TABLE channel ADD COLUMN iptvid SMALLINT(6) UNSIGNED;",
2040 "CREATE TABLE iptv_channel ("
2041 " iptvid SMALLINT(6) UNSIGNED NOT NULL auto_increment,"
2042 " chanid INT(10) UNSIGNED NOT NULL,"
2043 " url TEXT NOT NULL,"
2044 " type set('data', "
2045 " 'rfc2733-1','rfc2733-2', "
2046 " 'rfc5109-1','rfc5109-2', "
2047 " 'smpte2022-1','smpte2022-2'),"
2048 " bitrate INT(10) UNSIGNED NOT NULL,"
2049 " PRIMARY KEY (iptvid)"
2050 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2051 nullptr
2052 };
2053 
2054  if (!performActualUpdate(updates, "1301", dbver))
2055  return false;
2056  }
2057 
2058  if (dbver == "1301")
2059  {
2060  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1302");
2061  // Create the Default recording rule template
2062  RecordingRule record;
2063  record.MakeTemplate("Default");
2064  record.m_type = kTemplateRecord;
2065  // Take some defaults from now obsoleted settings.
2066  record.m_startOffset =
2067  gCoreContext->GetNumSetting("DefaultStartOffset", 0);
2068  record.m_endOffset =
2069  gCoreContext->GetNumSetting("DefaultEndOffset", 0);
2070  record.m_dupMethod =
2071  static_cast<RecordingDupMethodType>(
2073  "prefDupMethod", kDupCheckSubDesc));
2075  record.m_autoExpire =
2076  gCoreContext->GetBoolSetting("AutoExpireDefault", false);
2077  record.m_autoCommFlag =
2078  gCoreContext->GetBoolSetting("AutoCommercialFlag", true);
2079  record.m_autoTranscode =
2080  gCoreContext->GetBoolSetting("AutoTranscode", false);
2081  record.m_transcoder =
2083  "DefaultTranscoder", static_cast<int>(RecordingProfile::TranscoderAutodetect));
2084  record.m_autoUserJob1 =
2085  gCoreContext->GetBoolSetting("AutoRunUserJob1", false);
2086  record.m_autoUserJob2 =
2087  gCoreContext->GetBoolSetting("AutoRunUserJob2", false);
2088  record.m_autoUserJob3 =
2089  gCoreContext->GetBoolSetting("AutoRunUserJob3", false);
2090  record.m_autoUserJob4 =
2091  gCoreContext->GetBoolSetting("AutoRunUserJob4", false);
2092  record.m_autoMetadataLookup =
2093  gCoreContext->GetBoolSetting("AutoMetadataLookup", true);
2094  record.Save(false);
2095 
2096  if (!UpdateDBVersionNumber("1302", dbver))
2097  return false;
2098  }
2099 
2100  if (dbver == "1302")
2101  {
2102  QDateTime loc = QDateTime::currentDateTime();
2103  QDateTime utc = loc.toUTC();
2104  loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
2105  int utc_offset = loc.secsTo(utc) / 60;
2106 
2107  QList<QByteArray> updates_ba;
2108 
2109  // Convert DATE and TIME in record into DATETIME
2110  const char *pre_sql[] = {
2111  "CREATE TEMPORARY TABLE recordupdate ("
2112  "recid INT, starttime DATETIME, endtime DATETIME)",
2113  "INSERT INTO recordupdate (recid, starttime, endtime) "
2114  "SELECT recordid, "
2115  " CONCAT(startdate, ' ', starttime), "
2116  " CONCAT(enddate, ' ', endtime) FROM record",
2117  };
2118  for (uint i = 0; i < sizeof(pre_sql)/sizeof(char*); i++)
2119  updates_ba.push_back(QByteArray(pre_sql[i]));
2120 
2121  // Convert various DATETIME fields from local time to UTC
2122  if (0 != utc_offset)
2123  {
2124  const char *with_endtime[] = {
2125  "program", "recorded", "oldrecorded", "recordupdate",
2126  };
2127  const char *without_endtime[] = {
2128  "programgenres", "programrating", "credits",
2129  "jobqueue",
2130  };
2131  QString order = (utc_offset > 0) ? "-starttime" : "starttime";
2132 
2133  for (uint i = 0; i < sizeof(with_endtime)/sizeof(char*); i++)
2134  {
2135  updates_ba.push_back(
2136  QString("UPDATE %1 "
2137  "SET starttime = "
2138  " CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC'), "
2139  " endtime = "
2140  " CONVERT_TZ(endtime, 'SYSTEM', 'Etc/UTC') "
2141  "ORDER BY %4")
2142  .arg(with_endtime[i])
2143  .arg(order).toLocal8Bit());
2144  }
2145 
2146  for (uint i = 0; i < sizeof(without_endtime)/sizeof(char*); i++)
2147  {
2148  updates_ba.push_back(
2149  QString("UPDATE %1 "
2150  "SET starttime = "
2151  " CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC') "
2152  "ORDER BY %3")
2153  .arg(without_endtime[i]).arg(order)
2154  .toLocal8Bit());
2155  }
2156 
2157  updates_ba.push_back(
2158  QString("UPDATE oldprogram "
2159  "SET airdate = "
2160  " CONVERT_TZ(airdate, 'SYSTEM', 'Etc/UTC') "
2161  "ORDER BY %3")
2162  .arg((utc_offset > 0) ? "-airdate" :
2163  "airdate").toLocal8Bit());
2164 
2165  updates_ba.push_back(
2166  QString("UPDATE recorded "
2167  "set progstart = "
2168  " CONVERT_TZ(progstart, 'SYSTEM', 'Etc/UTC'), "
2169  " progend = "
2170  " CONVERT_TZ(progend, 'SYSTEM', 'Etc/UTC') ")
2171  .toLocal8Bit());
2172  }
2173 
2174  // Convert DATETIME back to separate DATE and TIME in record table
2175  const char *post_sql[] = {
2176  "UPDATE record, recordupdate "
2177  "SET record.startdate = DATE(recordupdate.starttime), "
2178  " record.starttime = TIME(recordupdate.starttime), "
2179  " record.enddate = DATE(recordupdate.endtime), "
2180  " record.endtime = TIME(recordupdate.endtime), "
2181  " record.last_record = "
2182  " CONVERT_TZ(last_record, 'SYSTEM', 'Etc/UTC'), "
2183  " record.last_delete = "
2184  " CONVERT_TZ(last_delete, 'SYSTEM', 'Etc/UTC') "
2185  "WHERE recordid = recid",
2186  "DROP TABLE recordupdate",
2187  };
2188 
2189  for (uint i = 0; i < sizeof(post_sql)/sizeof(char*); i++)
2190  updates_ba.push_back(QByteArray(post_sql[i]));
2191 
2192  // Convert update ByteArrays to NULL terminated char**
2193  QList<QByteArray>::const_iterator it = updates_ba.begin();
2194  vector<const char*> updates;
2195  for (; it != updates_ba.end(); ++it)
2196  updates.push_back((*it).constData());
2197  updates.push_back(nullptr);
2198 
2199  // do the actual update
2200  if (!performActualUpdate(&updates[0], "1303", dbver))
2201  return false;
2202  }
2203 
2204  if (dbver == "1303")
2205  {
2206  QDateTime loc = QDateTime::currentDateTime();
2207  QDateTime utc = loc.toUTC();
2208  loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
2209  int utc_offset = loc.secsTo(utc) / 60;
2210 
2211  QList<QByteArray> updates_ba;
2212 
2213  // Convert various DATETIME fields from local time to UTC
2214  if (0 != utc_offset)
2215  {
2216  const char *with_endtime[] = {
2217  "recordedprogram",
2218  };
2219  const char *without_endtime[] = {
2220  "recordedseek", "recordedmarkup", "recordedrating",
2221  "recordedcredits",
2222  };
2223  QString order = (utc_offset > 0) ? "-starttime" : "starttime";
2224 
2225  for (uint i = 0; i < sizeof(with_endtime)/sizeof(char*); i++)
2226  {
2227  updates_ba.push_back(
2228  QString("UPDATE %1 "
2229  "SET starttime = CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC'), "
2230  " endtime = CONVERT_TZ(endtime, 'SYSTEM', 'Etc/UTC') "
2231  "ORDER BY %4")
2232  .arg(with_endtime[i]).arg(order).toLocal8Bit());
2233  }
2234 
2235  for (uint i = 0; i < sizeof(without_endtime)/sizeof(char*); i++)
2236  {
2237  updates_ba.push_back(
2238  QString("UPDATE %1 "
2239  "SET starttime = CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC') "
2240  "ORDER BY %3")
2241  .arg(without_endtime[i]).arg(order).toLocal8Bit());
2242  }
2243  }
2244 
2245  // Convert update ByteArrays to NULL terminated char**
2246  QList<QByteArray>::const_iterator it = updates_ba.begin();
2247  vector<const char*> updates;
2248  for (; it != updates_ba.end(); ++it)
2249  updates.push_back((*it).constData());
2250  updates.push_back(nullptr);
2251 
2252  // do the actual update
2253  if (!performActualUpdate(&updates[0], "1304", dbver))
2254  return false;
2255  }
2256 
2257  if (dbver == "1304")
2258  {
2259  QList<QByteArray> updates_ba;
2260 
2261  updates_ba.push_back(
2262 "UPDATE recordfilter SET clause="
2263 "'HOUR(CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM'')) >= 19 AND "
2264 "HOUR(CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM'')) < 22' "
2265 "WHERE filterid=3");
2266 
2267  updates_ba.push_back(QString(
2268 "UPDATE record SET findday = "
2269 " DAYOFWEEK(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2270 " 'SYSTEM', 'Etc/UTC') + INTERVAL findday DAY) "
2271 "WHERE findday > 0").toLocal8Bit());
2272 
2273  updates_ba.push_back(QString(
2274 "UPDATE record SET findtime = "
2275 " TIME(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2276 " 'SYSTEM', 'Etc/UTC')) ")
2277  .toLocal8Bit());
2278 
2279  // Convert update ByteArrays to NULL terminated char**
2280  QList<QByteArray>::const_iterator it = updates_ba.begin();
2281  vector<const char*> updates;
2282  for (; it != updates_ba.end(); ++it)
2283  updates.push_back((*it).constData());
2284  updates.push_back(nullptr);
2285 
2286  if (!performActualUpdate(&updates[0], "1305", dbver))
2287  return false;
2288  }
2289 
2290  if (dbver == "1305")
2291  {
2292  // Reverse the findday/findtime changes from above since those
2293  // values need to be kept in local time.
2294 
2295  QList<QByteArray> updates_ba;
2296 
2297  updates_ba.push_back(QString(
2298 "UPDATE record SET findday = "
2299 " DAYOFWEEK(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2300 " 'Etc/UTC', 'SYSTEM') + INTERVAL findday DAY) "
2301 "WHERE findday > 0").toLocal8Bit());
2302 
2303  updates_ba.push_back(QString(
2304 "UPDATE record SET findtime = "
2305 " TIME(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2306 " 'Etc/UTC', 'SYSTEM')) ").toLocal8Bit());
2307 
2308  // Convert update ByteArrays to NULL terminated char**
2309  QList<QByteArray>::const_iterator it = updates_ba.begin();
2310  vector<const char*> updates;
2311  for (; it != updates_ba.end(); ++it)
2312  updates.push_back((*it).constData());
2313  updates.push_back(nullptr);
2314 
2315  if (!performActualUpdate(&updates[0], "1306", dbver))
2316  return false;
2317  }
2318 
2319  if (dbver == "1306")
2320  {
2321  // staging temporary tables to use with rewritten file scanner
2322  // due to be replaced by finalized RecordedFile changes
2323 
2324  const char *updates[] = {
2325 "CREATE TABLE scannerfile ("
2326 " `fileid` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,"
2327 " `filesize` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,"
2328 " `filehash` VARCHAR(64) NOT NULL DEFAULT '',"
2329 " `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,"
2330 " PRIMARY KEY (`fileid`),"
2331 " UNIQUE KEY filehash (`filehash`)"
2332 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2333 "CREATE TABLE scannerpath ("
2334 " `fileid` BIGINT(20) UNSIGNED NOT NULL,"
2335 " `hostname` VARCHAR(64) NOT NULL DEFAULT 'localhost',"
2336 " `storagegroup` VARCHAR(32) NOT NULL DEFAULT 'Default',"
2337 " `filename` VARCHAR(255) NOT NULL DEFAULT '',"
2338 " PRIMARY KEY (`fileid`)"
2339 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2340 "CREATE TABLE videopart ("
2341 " `fileid` BIGINT(20) UNSIGNED NOT NULL,"
2342 " `videoid` INT(10) UNSIGNED NOT NULL,"
2343 " `order` SMALLINT UNSIGNED NOT NULL DEFAULT 1,"
2344 " PRIMARY KEY `part` (`videoid`, `order`)"
2345 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2346 nullptr
2347 };
2348 
2349 // removed "UNIQUE KEY path (`storagegroup`, `hostname`, `filename`)" from
2350 // scannerpath as a quick fix for key length constraints
2351 
2352  if (!performActualUpdate(updates, "1307", dbver))
2353  return false;
2354  }
2355 
2356  if (dbver == "1307")
2357  {
2358  const char *updates[] = {
2359 "ALTER TABLE channel MODIFY COLUMN icon varchar(255) NOT NULL DEFAULT '';",
2360 "UPDATE channel SET icon='' WHERE icon='none';",
2361 nullptr
2362 };
2363  if (!performActualUpdate(updates, "1308", dbver))
2364  return false;
2365  }
2366 
2367  if (dbver == "1308")
2368  {
2369  const char *updates[] = {
2370 // Add this time filter
2371 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2372 " VALUES (8, 'This time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2373 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2374 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 1440 <= 10', 0)",
2375 // Add this day and time filter
2376 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2377 " VALUES (9, 'This day and time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2378 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2379 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 10080 <= 10', 0)",
2380 // Convert old, normal Timeslot rules to Channel with time filter
2381 "UPDATE record SET type = 3, filter = filter|256 "
2382 " WHERE type = 2 AND search = 0",
2383 // Convert old, normal Weekslot rules to Channel with day and time filter
2384 "UPDATE record SET type = 3, filter = filter|512 "
2385 " WHERE type = 5 AND search = 0",
2386 // Convert old, normal find daily to new, power search, find daily
2387 "UPDATE record SET type = 2, search = 1, chanid = 0, station = '', "
2388 " subtitle = '', description = CONCAT('program.title = ''', "
2389 " REPLACE(title, '''', ''''''), ''''), "
2390 " title = CONCAT(title, ' (Power Search)') WHERE type = 9 AND search = 0",
2391 // Convert old, normal find weekly to new, power search, find weekly
2392 "UPDATE record SET type = 5, search = 1, chanid = 0, station = '', "
2393 " subtitle = '', description = CONCAT('program.title = ''', "
2394 " REPLACE(title, '''', ''''''), ''''), "
2395 " title = CONCAT(title, ' (Power Search)') WHERE type = 10 AND search = 0",
2396 // Convert old, find daily to new, find daily
2397 "UPDATE record SET type = 2 WHERE type = 9",
2398 // Convert old, find weekly to new, find weekly
2399 "UPDATE record SET type = 5 WHERE type = 10",
2400 nullptr
2401 };
2402  if (!performActualUpdate(updates, "1309", dbver))
2403  return false;
2404  }
2405 
2406  if (dbver == "1309")
2407  {
2408  const char *updates[] = {
2409 // Add this channel filter
2410 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2411 " VALUES (10, 'This channel', 'channel.callsign = RECTABLE.station', 0)",
2412 // Convert old, Channel rules to All with channel filter
2413 "UPDATE record SET type = 4, filter = filter|1024 WHERE type = 3",
2414 nullptr
2415 };
2416  if (!performActualUpdate(updates, "1310", dbver))
2417  return false;
2418  }
2419 
2420  if (dbver == "1310")
2421  {
2422  const char *updates[] = {
2423 // Move old table temporarily
2424 "RENAME TABLE `housekeeping` TO `oldhousekeeping`;",
2425 // Create new table in its place
2426 "CREATE TABLE `housekeeping` ("
2427 " `tag` VARCHAR(64) NOT NULL,"
2428 " `hostname` VARCHAR(64),"
2429 " `lastrun` DATETIME,"
2430 " UNIQUE KEY `task` (`tag`, `hostname`)"
2431 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2432 // Migrate old data over
2433 "INSERT INTO `housekeeping` (`tag`, `hostname`, `lastrun`)"
2434 " SELECT SUBSTRING_INDEX(`tag`, '-', 1) AS `tag`,"
2435 " IF(LOCATE('-', `tag`) > 0,"
2436 " SUBSTRING(`tag` FROM LENGTH(SUBSTRING_INDEX(`tag`, '-', 1)) +2),"
2437 " NULL) AS `hostname`,"
2438 " `lastrun`"
2439 " FROM `oldhousekeeping`;",
2440 // Delete old data
2441 "DROP TABLE `oldhousekeeping`;",
2442 nullptr
2443 };
2444 
2445  if (!performActualUpdate(updates, "1311", dbver))
2446  return false;
2447  }
2448 
2449  if (dbver == "1311")
2450  {
2451  const char *updates[] = {
2452 // Create a global enable/disable instead of one per-host
2453 // Any hosts previously running it mean all hosts do now
2454 "INSERT INTO `settings` (`value`, `hostname`, `data`)"
2455 " SELECT 'HardwareProfileEnabled',"
2456 " NULL,"
2457 " IF((SELECT COUNT(1)"
2458 " FROM `settings`"
2459 " WHERE `value` = 'HardwareProfileLastUpdated' > 0),"
2460 " 1, 0);",
2461 // Create 'lastrun' times using existing data in settings
2462 "INSERT INTO `housekeeping` (`tag`, `hostname`, `lastrun`)"
2463 " SELECT 'HardwareProfiler',"
2464 " `hostname`,"
2465 " `data`"
2466 " FROM `settings`"
2467 " WHERE `value` = 'HardwareProfileLastUpdated';",
2468 // Clear out old settings
2469 "DELETE FROM `settings` WHERE `value` = 'HardwareProfileLastUpdated';",
2470 nullptr
2471 };
2472  if (!performActualUpdate(updates, "1312", dbver))
2473  return false;
2474  }
2475 
2476  if (dbver == "1312")
2477  {
2478  const char *updates[] = {
2479 // DVD bookmark updates
2480 "DELETE FROM `dvdbookmark` WHERE `framenum` = 0;",
2481 "ALTER TABLE dvdbookmark ADD COLUMN dvdstate varchar(1024) NOT NULL DEFAULT '';",
2482 nullptr
2483 };
2484  if (!performActualUpdate(updates, "1313", dbver))
2485  return false;
2486  }
2487 
2488  if (dbver == "1313")
2489  {
2490  // Make sure channel timeouts are long enough. No actual
2491  // schema change.
2492  const char *updates[] = {
2493  "UPDATE capturecard SET channel_timeout = 3000 WHERE "
2494  "cardtype = \"DVB\" AND channel_timeout < 3000;",
2495  "UPDATE capturecard SET channel_timeout = 30000 WHERE "
2496  "cardtype = \"FREEBOX\" AND channel_timeout < 30000;",
2497  "UPDATE capturecard SET channel_timeout = 9000 WHERE "
2498  "cardtype = \"FIREWIRE\" AND channel_timeout < 9000;",
2499  "UPDATE capturecard SET channel_timeout = 3000 WHERE "
2500  "cardtype = \"HDHOMERUN\" AND channel_timeout < 3000;",
2501  "UPDATE capturecard SET channel_timeout = 15000 WHERE "
2502  "cardtype = \"HDPVR\" AND channel_timeout < 15000;",
2503  "UPDATE capturecard SET channel_timeout = 12000 WHERE "
2504  "cardtype = \"MPEG\" AND channel_timeout < 12000;",
2505  nullptr
2506  };
2507  if (!performActualUpdate(updates, "1314", dbver))
2508  return false;
2509  }
2510 
2511  if (dbver == "1314")
2512  {
2513  // Migrate users from tmdb.py to tmdb3.py
2514  // The web interface tmdb.py uses will be shut down 2013-09-15
2515  const char *updates[] = {
2516  "UPDATE settings SET data=REPLACE(data, 'tmdb.py', 'tmdb3.py') "
2517  "WHERE value='MovieGrabber'",
2518  nullptr
2519  };
2520  if (!performActualUpdate(updates, "1315", dbver))
2521  return false;
2522  }
2523 
2524  if (dbver == "1315")
2525  {
2526  const char *updates[] = {
2527 "ALTER TABLE program ADD INDEX title_subtitle_start (title, subtitle, starttime);",
2528 "ALTER TABLE program DROP INDEX title;",
2529 nullptr
2530 };
2531  if (!performActualUpdate(updates, "1316", dbver))
2532  return false;
2533  }
2534 
2535  if (dbver == "1316")
2536  {
2537  const char *updates[] = {
2538 // adjust programid type in various tables to match the program table
2539 "ALTER TABLE oldrecorded CHANGE COLUMN programid programid varchar(64);",
2540 "ALTER TABLE oldrecorded CHANGE COLUMN seriesid seriesid varchar(64);",
2541 "ALTER TABLE record CHANGE COLUMN programid programid varchar(64);",
2542 "ALTER TABLE record CHANGE COLUMN seriesid seriesid varchar(64);",
2543 "ALTER TABLE recorded CHANGE COLUMN programid programid varchar(64);",
2544 "ALTER TABLE recorded CHANGE COLUMN seriesid seriesid varchar(64);",
2545 "ALTER TABLE recordedprogram CHANGE COLUMN programid programid varchar(64);",
2546 "ALTER TABLE recordedprogram CHANGE COLUMN seriesid seriesid varchar(64);",
2547 nullptr
2548 };
2549  if (!performActualUpdate(updates, "1317", dbver))
2550  return false;
2551  }
2552 
2553  if (dbver == "1317")
2554  {
2555  const char *updates[] = {
2556  "CREATE TABLE IF NOT EXISTS gallery_directories ("
2557  " dir_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
2558  " filename VARCHAR(255) NOT NULL,"
2559  " name VARCHAR(255) NOT NULL,"
2560  " path VARCHAR(255) NOT NULL,"
2561  " parent_id INT(11) NOT NULL,"
2562  " dir_count INT(11) NOT NULL DEFAULT '0',"
2563  " file_count INT(11) NOT NULL DEFAULT '0',"
2564  " hidden TINYINT(1) NOT NULL DEFAULT '0'"
2565  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2566  "CREATE TABLE IF NOT EXISTS gallery_files ("
2567  " file_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
2568  " filename VARCHAR(255) NOT NULL,"
2569  " name VARCHAR(255) NOT NULL,"
2570  " path VARCHAR(255) NOT NULL,"
2571  " dir_id INT(11) NOT NULL DEFAULT '0',"
2572  " type INT(11) NOT NULL DEFAULT '0',"
2573  " modtime INT(11) NOT NULL DEFAULT '0',"
2574  " size INT(11) NOT NULL DEFAULT '0',"
2575  " extension VARCHAR(255) NOT NULL,"
2576  " angle INT(11) NOT NULL DEFAULT '0',"
2577  " date INT(11) NOT NULL DEFAULT '0',"
2578  " zoom INT(11) NOT NULL DEFAULT '0',"
2579  " hidden TINYINT(1) NOT NULL DEFAULT '0',"
2580  " orientation INT(11) NOT NULL DEFAULT '0'"
2581  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2582  "INSERT INTO settings VALUES ('ImageStorageGroupName', 'Images', NULL);",
2583  "INSERT INTO settings VALUES ('ImageSortOrder', 0, NULL);",
2584  "INSERT INTO settings VALUES ('ImageShowHiddenFiles', 0, NULL);",
2585  "INSERT INTO settings VALUES ('ImageSlideShowTime', 3500, NULL);",
2586  "INSERT INTO settings VALUES ('ImageTransitionType', 1, NULL);",
2587  "INSERT INTO settings VALUES ('ImageTransitionTime', 1000, NULL);",
2588  nullptr
2589  };
2590 
2591  if (!performActualUpdate(&updates[0], "1318", dbver))
2592  return false;
2593  }
2594 
2595  if (dbver == "1318")
2596  {
2597  const char *updates[] = {
2598  "ALTER TABLE program "
2599  " ADD COLUMN season INT(4) NOT NULL DEFAULT '0', "
2600  " ADD COLUMN episode INT(4) NOT NULL DEFAULT '0';",
2601  "ALTER TABLE recordedprogram "
2602  " ADD COLUMN season INT(4) NOT NULL DEFAULT '0', "
2603  " ADD COLUMN episode INT(4) NOT NULL DEFAULT '0';",
2604  nullptr
2605  };
2606 
2607  if (!performActualUpdate(&updates[0], "1319", dbver))
2608  return false;
2609  }
2610 
2611  if (dbver == "1319")
2612  {
2613  // Total number of episodes in the series (season)
2614  const char *updates[] = {
2615  "ALTER TABLE program "
2616  " ADD COLUMN totalepisodes INT(4) NOT NULL DEFAULT '0';",
2617  "ALTER TABLE recordedprogram "
2618  " ADD COLUMN totalepisodes INT(4) NOT NULL DEFAULT '0';",
2619  nullptr
2620  };
2621 
2622  if (!performActualUpdate(&updates[0], "1320", dbver))
2623  return false;
2624  }
2625 
2626  if (dbver == "1320")
2627  {
2628  const char *updates[] = {
2629  "CREATE TABLE IF NOT EXISTS recgroups ("
2630  "recgroupid SMALLINT(4) NOT NULL AUTO_INCREMENT, "
2631  "recgroup VARCHAR(64) NOT NULL DEFAULT '', "
2632  "displayname VARCHAR(64) NOT NULL DEFAULT '', "
2633  "password VARCHAR(40) NOT NULL DEFAULT '', "
2634  "special TINYINT(1) NOT NULL DEFAULT '0',"
2635  "PRIMARY KEY (recgroupid), "
2636  "UNIQUE KEY recgroup ( recgroup )"
2637  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2638  // Create the built-in, 'special', groups
2639  "INSERT INTO recgroups ( recgroupid, recgroup, special ) VALUES ( 1, 'Default', '1' );",
2640  "INSERT INTO recgroups ( recgroupid, recgroup, special ) VALUES ( 2, 'LiveTV', '1' );",
2641  "INSERT INTO recgroups ( recgroupid, recgroup, special ) VALUES ( 3, 'Deleted', '1' );",
2642  // Copy in the passwords for the built-in groups
2643  "DELETE FROM recgrouppassword WHERE password = '';",
2644  "UPDATE recgroups r, recgrouppassword p SET r.password = p.password WHERE r.recgroup = p.recgroup;",
2645  // Copy over all existing recording groups, this information may be split over three tables!
2646  "INSERT IGNORE INTO recgroups ( recgroup, displayname, password ) SELECT DISTINCT recgroup, recgroup, password FROM recgrouppassword;",
2647  "INSERT IGNORE INTO recgroups ( recgroup, displayname ) SELECT DISTINCT recgroup, recgroup FROM record;",
2648  "INSERT IGNORE INTO recgroups ( recgroup, displayname ) SELECT DISTINCT recgroup, recgroup FROM recorded;",
2649  // Create recgroupid columns in record and recorded tables
2650  "ALTER TABLE record ADD COLUMN recgroupid SMALLINT(4) NOT NULL DEFAULT '1', ADD INDEX ( recgroupid );",
2651  "ALTER TABLE recorded ADD COLUMN recgroupid SMALLINT(4) NOT NULL DEFAULT '1', ADD INDEX ( recgroupid );",
2652  // Populate those columns with the corresponding recgroupid from the new recgroups table
2653  "UPDATE recorded, recgroups SET recorded.recgroupid = recgroups.recgroupid WHERE recorded.recgroup = recgroups.recgroup;",
2654  "UPDATE record, recgroups SET record.recgroupid = recgroups.recgroupid WHERE record.recgroup = recgroups.recgroup;",
2655  nullptr
2656  };
2657 
2658 
2659 
2660  if (!performActualUpdate(&updates[0], "1321", dbver))
2661  return false;
2662  }
2663 
2664  if (dbver == "1321")
2665  {
2666  const char *updates[] = {
2667  "ALTER TABLE `housekeeping` ADD COLUMN `lastsuccess` DATETIME;",
2668  "UPDATE `housekeeping` SET `lastsuccess`=`lastrun`;",
2669  nullptr
2670  };
2671 
2672  if (!performActualUpdate(&updates[0], "1322", dbver))
2673  return false;
2674  }
2675 
2676  if (dbver == "1322")
2677  {
2678  const char *updates[] = {
2679  // add inetref to (recorded)program before season/episode
2680  "ALTER TABLE program "
2681  " ADD COLUMN inetref varchar(40) DEFAULT '' AFTER videoprop;",
2682  "ALTER TABLE recordedprogram "
2683  " ADD COLUMN inetref varchar(40) DEFAULT '' AFTER videoprop;",
2684  "DELETE FROM settings WHERE value='DefaultStartOffset';",
2685  "DELETE FROM settings WHERE value='DefaultEndOffset';",
2686  "DELETE FROM settings WHERE value='AutoExpireDefault';",
2687  "DELETE FROM settings WHERE value='AutoCommercialFlag';",
2688  "DELETE FROM settings WHERE value='AutoTranscode';",
2689  "DELETE FROM settings WHERE value='DefaultTranscoder';",
2690  "DELETE FROM settings WHERE value='AutoRunUserJob1';",
2691  "DELETE FROM settings WHERE value='AutoRunUserJob2';",
2692  "DELETE FROM settings WHERE value='AutoRunUserJob3';",
2693  "DELETE FROM settings WHERE value='AutoRunUserJob4';",
2694  "DELETE FROM settings WHERE value='AutoMetadataLookup';",
2695  "DELETE FROM housekeeping WHERE tag='DailyCleanup';",
2696  "DELETE FROM housekeeping WHERE tag='ThemeChooserInfoCacheUpdate';",
2697  nullptr
2698  };
2699  if (!performActualUpdate(updates, "1323", dbver))
2700  return false;
2701  }
2702 
2703  if (dbver == "1323")
2704  {
2705  const char *updates[] = {
2706  // add columns for Unicable related configuration data, see #9726
2707  "ALTER TABLE diseqc_tree "
2708  " ADD COLUMN scr_userband INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER address, "
2709  " ADD COLUMN scr_frequency INTEGER UNSIGNED NOT NULL DEFAULT 1400 AFTER scr_userband, "
2710  " ADD COLUMN scr_pin INTEGER NOT NULL DEFAULT '-1' AFTER scr_frequency;",
2711  nullptr
2712  };
2713 
2714  if (!performActualUpdate(updates, "1324", dbver))
2715  return false;
2716  }
2717 
2718  if (dbver == "1324")
2719  {
2720  const char *updates[] = {
2721  "ALTER TABLE recorded "
2722  " DROP PRIMARY KEY, "
2723  " ADD recordedid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, "
2724  " ADD UNIQUE KEY (chanid, starttime) ;",
2725  nullptr
2726  };
2727 
2728  if (!performActualUpdate(updates, "1325", dbver))
2729  return false;
2730  }
2731 
2732  if (dbver == "1325")
2733  {
2734  const char *updates[] = {
2735  "ALTER TABLE recorded ADD inputname VARCHAR(32);",
2736  nullptr
2737  };
2738 
2739  if (!performActualUpdate(&updates[0], "1326", dbver))
2740  return false;
2741  }
2742 
2743  if (dbver == "1326")
2744  {
2745  const char *updates[] = {
2746 // Add this time filter
2747 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2748 " VALUES (8, 'This time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2749 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2750 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 1440 "
2751 " NOT BETWEEN 11 AND 1429', 0)",
2752 // Add this day and time filter
2753 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2754 " VALUES (9, 'This day and time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2755 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2756 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 10080 "
2757 " NOT BETWEEN 11 AND 10069', 0)",
2758 nullptr
2759 };
2760  if (!performActualUpdate(updates, "1327", dbver))
2761  return false;
2762  }
2763 
2764  if (dbver == "1327")
2765  {
2766  const char *updates[] = {
2767  "DELETE r1 FROM record r1, record r2 "
2768  " WHERE r1.chanid = r2.chanid AND "
2769  " r1.starttime = r2.starttime AND "
2770  " r1.startdate = r2.startdate AND "
2771  " r1.title = r2.title AND "
2772  " r1.type = r2.type AND "
2773  " r1.recordid > r2.recordid",
2774  "ALTER TABLE record DROP INDEX chanid",
2775  "ALTER TABLE record ADD UNIQUE INDEX "
2776  " (chanid, starttime, startdate, title, type)",
2777  nullptr
2778  };
2779  if (!performActualUpdate(updates, "1328", dbver))
2780  return false;
2781  }
2782 
2783  if (dbver == "1328")
2784  {
2785  const char *updates[] = {
2786  "ALTER TABLE recordedfile "
2787  "DROP KEY `chanid`, "
2788  "DROP COLUMN `chanid`, "
2789  "DROP COLUMN `starttime`;",
2790  "ALTER TABLE recordedfile "
2791  "ADD COLUMN recordedid int(10) unsigned NOT NULL, "
2792  "ADD UNIQUE KEY `recordedid` (recordedid);",
2793  "ALTER TABLE recordedfile "
2794  "CHANGE audio_type audio_codec varchar(255) NOT NULL DEFAULT '';"
2795  "ALTER TABLE recordedfile "
2796  "CHANGE video_type video_codec varchar(255) NOT NULL DEFAULT '';",
2797  nullptr
2798  };
2799  if (!performActualUpdate(updates, "1329", dbver))
2800  return false;
2801  }
2802 
2803  if (dbver == "1329")
2804  {
2805  const char *updates[] = {
2806  "ALTER TABLE recordedfile "
2807  "DROP COLUMN audio_bits_per_sample ;", // Instead create two columns for avg and max bitrates
2808  "ALTER TABLE recordedfile "
2809  "ADD COLUMN container VARCHAR(255) NOT NULL DEFAULT '', "
2810  "ADD COLUMN total_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2811  "ADD COLUMN video_avg_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2812  "ADD COLUMN video_max_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2813  "ADD COLUMN audio_avg_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2814  "ADD COLUMN audio_max_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0 ;", // Kbps
2815  nullptr
2816  };
2817  if (!performActualUpdate(updates, "1330", dbver))
2818  return false;
2819  }
2820 
2821  if (dbver == "1330")
2822  {
2823  MSqlQuery query(MSqlQuery::InitCon());
2824  query.prepare("SELECT recordedid FROM recorded");
2825  query.exec();
2826  while (query.next())
2827  {
2828  int recordingID = query.value(0).toInt();
2829  RecordingInfo *recInfo = new RecordingInfo(recordingID);
2830  RecordingFile *recFile = recInfo->GetRecordingFile();
2831  recFile->m_fileName = recInfo->GetBasename();
2832  recFile->m_fileSize = recInfo->GetFilesize();
2833  recFile->m_storageGroup = recInfo->GetStorageGroup();
2834  recFile->m_storageDeviceID = recInfo->GetHostname();
2835  switch (recInfo->QueryAverageAspectRatio())
2836  {
2837  case MARK_ASPECT_1_1 :
2838  recFile->m_videoAspectRatio = 1.0;
2839  break;
2840  case MARK_ASPECT_4_3:
2841  recFile->m_videoAspectRatio = 1.33333333333;
2842  break;
2843  case MARK_ASPECT_16_9:
2844  recFile->m_videoAspectRatio = 1.77777777777;
2845  break;
2846  case MARK_ASPECT_2_21_1:
2847  recFile->m_videoAspectRatio = 2.21;
2848  break;
2849  default:
2850  break;
2851  }
2852  QSize resolution(recInfo->QueryAverageWidth(),
2853  recInfo->QueryAverageHeight());
2854  recFile->m_videoResolution = resolution;
2855  recFile->m_videoFrameRate = (double)recInfo->QueryAverageFrameRate() / 1000.0;
2856  recFile->Save();
2857  delete recInfo;
2858  }
2859 
2860  if (!UpdateDBVersionNumber("1331", dbver))
2861  return false;
2862  }
2863 
2864  if (dbver == "1331")
2865  {
2866  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1332");
2867  MSqlQuery select(MSqlQuery::InitCon());
2868  MSqlQuery update(MSqlQuery::InitCon());
2869 
2870  // Find all second or higher inputs using the same card.
2871  select.prepare("SELECT DISTINCT i1.cardid, i1.cardinputid "
2872  "FROM cardinput i1, cardinput i2 "
2873  "WHERE i1.cardid = i2.cardid AND "
2874  " i1.cardinputid > i2.cardinputid "
2875  "ORDER BY i1.cardid, i1.cardinputid");
2876  if (!select.exec())
2877  {
2878  MythDB::DBError("Unable to retrieve cardinputids.", select);
2879  return false;
2880  }
2881 
2882  while (select.next())
2883  {
2884  int cardid = select.value(0).toInt();
2885  int inputid = select.value(1).toInt();
2886 
2887  // Create a new card for this input.
2888  update.prepare("INSERT INTO capturecard "
2889  " ( videodevice, audiodevice, vbidevice, "
2890  " cardtype, defaultinput, audioratelimit, "
2891  " hostname, dvb_swfilter, dvb_sat_type, "
2892  " dvb_wait_for_seqstart, skipbtaudio, "
2893  " dvb_on_demand, dvb_diseqc_type, "
2894  " firewire_speed, firewire_model, "
2895  " firewire_connection, signal_timeout, "
2896  " channel_timeout, dvb_tuning_delay, "
2897  " contrast, brightness, colour, hue, "
2898  " diseqcid, dvb_eitscan ) "
2899  "SELECT videodevice, audiodevice, vbidevice, "
2900  " cardtype, defaultinput, audioratelimit, "
2901  " hostname, dvb_swfilter, dvb_sat_type, "
2902  " dvb_wait_for_seqstart, skipbtaudio, "
2903  " dvb_on_demand, dvb_diseqc_type, "
2904  " firewire_speed, firewire_model, "
2905  " firewire_connection, signal_timeout, "
2906  " channel_timeout, dvb_tuning_delay, "
2907  " contrast, brightness, colour, hue, "
2908  " diseqcid, dvb_eitscan "
2909  "FROM capturecard c "
2910  "WHERE c.cardid = :CARDID");
2911  update.bindValue(":CARDID", cardid);
2912  if (!update.exec())
2913  {
2914  MythDB::DBError("Unable to insert new card.", update);
2915  return false;
2916  }
2917  int newcardid = update.lastInsertId().toInt();
2918 
2919  // Now attach the input to the new card.
2920  update.prepare("UPDATE cardinput "
2921  "SET cardid = :NEWCARDID "
2922  "WHERE cardinputid = :INPUTID");
2923  update.bindValue(":NEWCARDID", newcardid);
2924  update.bindValue(":INPUTID", inputid);
2925  if (!update.exec())
2926  {
2927  MythDB::DBError("Unable to update input.", update);
2928  return false;
2929  }
2930  }
2931 
2932  const char *updates[] = {
2933  // Delete old, automatically created inputgroups.
2934  "DELETE FROM inputgroup WHERE inputgroupname LIKE 'DVB_%'",
2935  "DELETE FROM inputgroup WHERE inputgroupname LIKE 'CETON_%'",
2936  "DELETE FROM inputgroup WHERE inputgroupname LIKE 'HDHOMERUN_%'",
2937  // Increase the size of inputgroup.inputgroupname.
2938  "ALTER TABLE inputgroup "
2939  " MODIFY COLUMN inputgroupname VARCHAR(48)",
2940  // Rename remaining inputgroups to have 'user:' prefix.
2941  "UPDATE inputgroup "
2942  " SET inputgroupname = CONCAT('user:', inputgroupname)",
2943  // Change inputgroup.inputid to equal cardid.
2944  "UPDATE inputgroup ig "
2945  " JOIN cardinput i ON ig.cardinputid = i.cardinputid "
2946  " SET ig.cardinputid = i.cardid",
2947  // Change record.prefinput to equal cardid.
2948  "UPDATE record r "
2949  " JOIN cardinput i ON r.prefinput = i.cardinputid "
2950  " SET r.prefinput = i.cardid",
2951  // Change diseqc_config.cardinputid to equal cardid.
2952  "UPDATE diseqc_config dc "
2953  " JOIN cardinput i ON dc.cardinputid = i.cardinputid "
2954  " SET dc.cardinputid = i.cardid",
2955  // Change cardinput.cardinputid to equal cardid. Do in
2956  // multiple steps to avoid duplicate ids.
2957  "SELECT MAX(cardid) INTO @maxcardid FROM capturecard",
2958  "SELECT MAX(cardinputid) INTO @maxcardinputid FROM cardinput",
2959  "UPDATE cardinput i "
2960  " SET i.cardinputid = i.cardid + @maxcardid + @maxcardinputid",
2961  "UPDATE cardinput i "
2962  " SET i.cardinputid = i.cardid",
2963  nullptr
2964  };
2965 
2966  if (!performUpdateSeries(updates))
2967  return false;
2968 
2969  // Create an automatically generated inputgroup for each card.
2970  select.prepare("SELECT cardid, hostname, videodevice "
2971  "FROM capturecard c "
2972  "ORDER BY c.cardid");
2973  if (!select.exec())
2974  {
2975  MythDB::DBError("Unable to retrieve cardtids.", select);
2976  return false;
2977  }
2978 
2979  while (select.next())
2980  {
2981  uint cardid = select.value(0).toUInt();
2982  QString host = select.value(1).toString();
2983  QString device = select.value(2).toString();
2984  QString name = host + "|" + device;
2986  if (!groupid)
2987  return false;
2988  if (!CardUtil::LinkInputGroup(cardid, groupid))
2989  return false;
2990  }
2991 
2992  // Remove orphan and administrative inputgroup entries.
2993  if (!CardUtil::UnlinkInputGroup(0, 0))
2994  return false;
2995 
2996  if (!UpdateDBVersionNumber("1332", dbver))
2997  return false;
2998  }
2999 
3000  if (dbver == "1332")
3001  {
3002  const char *updates[] = {
3003  // Move contents of cardinput to capturecard.
3004  "ALTER TABLE capturecard "
3005  " ADD COLUMN inputname VARCHAR(32) NOT NULL DEFAULT '', "
3006  " ADD COLUMN sourceid INT(10) UNSIGNED NOT NULL DEFAULT 0, "
3007  " ADD COLUMN externalcommand VARCHAR(128), "
3008  " ADD COLUMN changer_device VARCHAR(128), "
3009  " ADD COLUMN changer_model VARCHAR(128), "
3010  " ADD COLUMN tunechan VARCHAR(10), "
3011  " ADD COLUMN startchan VARCHAR(10), "
3012  " ADD COLUMN displayname VARCHAR(64) NOT NULL DEFAULT '', "
3013  " ADD COLUMN dishnet_eit TINYINT(1) NOT NULL DEFAULT 0, "
3014  " ADD COLUMN recpriority INT(11) NOT NULL DEFAULT 0, "
3015  " ADD COLUMN quicktune TINYINT(4) NOT NULL DEFAULT 0, "
3016  " ADD COLUMN schedorder INT(10) UNSIGNED NOT NULL DEFAULT 0, "
3017  " ADD COLUMN livetvorder INT(10) UNSIGNED NOT NULL DEFAULT 0",
3018  "UPDATE capturecard c "
3019  " JOIN cardinput i ON c.cardid = i.cardinputid "
3020  " SET c.inputname = i.inputname, "
3021  " c.sourceid = i.sourceid, "
3022  " c.externalcommand = i.externalcommand, "
3023  " c.changer_device = i.changer_device, "
3024  " c.changer_model = i.changer_model, "
3025  " c.tunechan = i.tunechan, "
3026  " c.startchan = i.startchan, "
3027  " c.displayname = i.displayname, "
3028  " c.dishnet_eit = i.dishnet_eit, "
3029  " c.recpriority = i.recpriority, "
3030  " c.quicktune = i.quicktune, "
3031  " c.schedorder = i.schedorder, "
3032  " c.livetvorder = i.livetvorder",
3033  "TRUNCATE cardinput",
3034  nullptr
3035  };
3036  if (!performActualUpdate(updates, "1333", dbver))
3037  return false;
3038  }
3039 
3040  if (dbver == "1333")
3041  {
3042  const char *updates[] = {
3043  // Fix default value of capturecard.inputname.
3044  "ALTER TABLE capturecard "
3045  " MODIFY COLUMN inputname VARCHAR(32) NOT NULL DEFAULT 'None'",
3046  "UPDATE capturecard c "
3047  " SET inputname = 'None' WHERE inputname = '' ",
3048  nullptr
3049  };
3050  if (!performActualUpdate(updates, "1334", dbver))
3051  return false;
3052  }
3053 
3054  if (dbver == "1334")
3055  {
3056  const char *updates[] = {
3057  // Change the default sched/livetvorder from 0 to 1.
3058  "ALTER TABLE capturecard "
3059  " MODIFY COLUMN schedorder INT(10) UNSIGNED "
3060  " NOT NULL DEFAULT 1, "
3061  " MODIFY COLUMN livetvorder INT(10) UNSIGNED "
3062  " NOT NULL DEFAULT 1",
3063  nullptr
3064  };
3065  if (!performActualUpdate(updates, "1335", dbver))
3066  return false;
3067  }
3068 
3069  if (dbver == "1335")
3070  {
3071  const char *updates[] = {
3072  // Fix custom record and custom priority references to
3073  // cardinput and cardinputid.
3074  "UPDATE record SET description = "
3075  " replace(description, 'cardinputid', 'cardid') "
3076  " WHERE search = 1",
3077  "UPDATE record SET description = "
3078  " replace(description, 'cardinput', 'capturecard') "
3079  " WHERE search = 1",
3080  "UPDATE powerpriority SET selectclause = "
3081  " replace(selectclause, 'cardinputid', 'cardid')",
3082  "UPDATE powerpriority SET selectclause = "
3083  " replace(selectclause, 'cardinput', 'capturecard')",
3084  nullptr
3085  };
3086  if (!performActualUpdate(updates, "1336", dbver))
3087  return false;
3088  }
3089 
3090  if (dbver == "1336")
3091  {
3092  const char *updates[] = {
3093  // Add a parentid columne to capturecard.
3094  "ALTER TABLE capturecard "
3095  " ADD parentid INT UNSIGNED NOT NULL DEFAULT 0 AFTER cardid",
3096  "UPDATE capturecard c, "
3097  " (SELECT min(cardid) cardid, hostname, videodevice, "
3098  " inputname, cardtype "
3099  " FROM capturecard "
3100  " WHERE cardtype NOT IN "
3101  " ('FREEBOX', 'IMPORT', 'DEMO', 'EXTERNAL') "
3102  " GROUP BY hostname, videodevice, inputname) mins "
3103  "SET c.parentid = mins.cardid "
3104  "WHERE c.hostname = mins.hostname and "
3105  " c.videodevice = mins.videodevice and "
3106  " c.inputname = mins.inputname and "
3107  " c.cardid <> mins.cardid",
3108  nullptr
3109  };
3110  if (!performActualUpdate(updates, "1337", dbver))
3111  return false;
3112  }
3113 
3114  if (dbver == "1337")
3115  {
3116  const char *updates[] = {
3117  // All next_record, last_record and last_delete to be NULL.
3118  "ALTER TABLE record MODIFY next_record DATETIME NULL",
3119  "UPDATE record SET next_record = NULL "
3120  " WHERE next_record = '0000-00-00 00:00:00'",
3121  "ALTER TABLE record MODIFY last_record DATETIME NULL",
3122  "UPDATE record SET last_record = NULL "
3123  " WHERE last_record = '0000-00-00 00:00:00'",
3124  "ALTER TABLE record MODIFY last_delete DATETIME NULL",
3125  "UPDATE record SET last_delete = NULL "
3126  " WHERE last_delete = '0000-00-00 00:00:00'",
3127  nullptr
3128  };
3129  if (!performActualUpdate(updates, "1338", dbver))
3130  return false;
3131  }
3132 
3133  if (dbver == "1338")
3134  {
3135  const char *updates[] = {
3136  "CREATE TABLE users ("
3137  " userid int(5) unsigned NOT NULL AUTO_INCREMENT,"
3138  " username varchar(128) NOT NULL DEFAULT '',"
3139  " password_digest varchar(32) NOT NULL DEFAULT '',"
3140  " lastlogin datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3141  " PRIMARY KEY (userid),"
3142  " KEY username (username)"
3143  " ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3144  "CREATE TABLE user_permissions ("
3145  " userid int(5) unsigned NOT NULL,"
3146  " permission varchar(128) NOT NULL DEFAULT '',"
3147  " PRIMARY KEY (userid)"
3148  " ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3149  "CREATE TABLE user_sessions ("
3150  " sessiontoken varchar(40) NOT NULL DEFAULT ''," // SHA1
3151  " userid int(5) unsigned NOT NULL,"
3152  " client varchar(128) NOT NULL, "
3153  " created datetime NOT NULL,"
3154  " lastactive datetime NOT NULL,"
3155  " expires datetime NOT NULL,"
3156  " PRIMARY KEY (sessionToken),"
3157  " UNIQUE KEY userid_client (userid,client)"
3158  " ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3159  "INSERT INTO users SET username='admin'," // Temporary default account
3160  " password_digest='bcd911b2ecb15ffbd6d8e6e744d60cf6';",
3161  nullptr
3162  };
3163  if (!performActualUpdate(updates, "1339", dbver))
3164  return false;
3165  }
3166 
3167  if (dbver == "1339")
3168  {
3169  MSqlQuery query(MSqlQuery::InitCon());
3170 
3171  // insert a new profile group for the VBox
3172  query.prepare("INSERT INTO profilegroups SET name = 'VBox Recorder', "
3173  "cardtype = 'VBOX', is_default = 1;");
3174  if (!query.exec())
3175  {
3176  MythDB::DBError("Unable to insert vbox profilegroup.", query);
3177  return false;
3178  }
3179 
3180  // get the id of the new profile group
3181  int groupid = query.lastInsertId().toInt();
3182 
3183  // insert the recording profiles
3184  query.prepare("INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = :GROUPID;");
3185  query.bindValue(":GROUPID", groupid);
3186  if (!query.exec())
3187  {
3188  MythDB::DBError("Unable to insert 'Default' recordingprofile.", query);
3189  return false;
3190  }
3191 
3192  query.prepare("INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = :GROUPID;");
3193  query.bindValue(":GROUPID", groupid);
3194  if (!query.exec())
3195  {
3196  MythDB::DBError("Unable to insert 'Live TV' recordingprofile.", query);
3197  return false;
3198  }
3199 
3200  query.prepare("INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = :GROUPID;");
3201  query.bindValue(":GROUPID", groupid);
3202  if (!query.exec())
3203  {
3204  MythDB::DBError("Unable to insert 'High Quality' recordingprofile.", query);
3205  return false;
3206  }
3207 
3208  query.prepare("INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = :GROUPID;");
3209  query.bindValue(":GROUPID", groupid);
3210  if (!query.exec())
3211  {
3212  MythDB::DBError("Unable to insert 'Low Quality' recordingprofile.", query);
3213  return false;
3214  }
3215 
3216  if (!UpdateDBVersionNumber("1340", dbver))
3217  return false;
3218  }
3219 
3220  if (dbver == "1340")
3221  {
3222  const char *updates[] = {
3223  // Add filter to ignore episodes (e.g. in a person search)
3224  "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
3225  " VALUES (11, 'No episodes', 'program.category_type <> ''series''', 0)",
3226  nullptr
3227  };
3228  if (!performActualUpdate(updates, "1341", dbver))
3229  return false;
3230  }
3231 
3232  if (dbver == "1341")
3233  {
3234  const char *updates[] = {
3235  "UPDATE profilegroups SET cardtype='FREEBOX' WHERE cardtype='Freebox'",
3236  nullptr
3237  };
3238  if (!performActualUpdate(updates, "1342", dbver))
3239  return false;
3240  }
3241 
3242  if (dbver == "1342")
3243  {
3244  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1343");
3245  MSqlQuery select(MSqlQuery::InitCon());
3246  MSqlQuery update(MSqlQuery::InitCon());
3247 
3248  const char *updates[] = {
3249  // Delete automatically created inputgroups.
3250  "DELETE FROM inputgroup WHERE inputgroupname REGEXP '^[a-z_-]*\\\\|'",
3251  // Increase the size of inputgroup.inputgroupname.
3252  "ALTER TABLE inputgroup "
3253  " MODIFY COLUMN inputgroupname VARCHAR(128)",
3254  nullptr
3255  };
3256 
3257  if (!performUpdateSeries(updates))
3258  return false;
3259 
3260  // Recreate automatically generated inputgroup for each card.
3261  select.prepare("SELECT cardid, parentid, cardtype, hostname, "
3262  " videodevice "
3263  "FROM capturecard c "
3264  "ORDER BY c.cardid");
3265  if (!select.exec())
3266  {
3267  MythDB::DBError("Unable to retrieve cardtids.", select);
3268  return false;
3269  }
3270 
3271  while (select.next())
3272  {
3273  uint cardid = select.value(0).toUInt();
3274  uint parentid = select.value(1).toUInt();
3275  QString type = select.value(2).toString();
3276  QString host = select.value(3).toString();
3277  QString device = select.value(4).toString();
3278  QString name = host + "|" + device;
3279  if (type == "FREEBOX" || type == "IMPORT" ||
3280  type == "DEMO" || type == "EXTERNAL")
3281  name += QString("|%1").arg(parentid ? parentid : cardid);
3283  if (!groupid)
3284  return false;
3285  if (!CardUtil::LinkInputGroup(cardid, groupid))
3286  return false;
3287  }
3288 
3289  // Remove orphan and administrative inputgroup entries.
3290  if (!CardUtil::UnlinkInputGroup(0, 0))
3291  return false;
3292 
3293  if (!UpdateDBVersionNumber("1343", dbver))
3294  return false;
3295  }
3296 
3297  if (dbver == "1343")
3298  {
3299  const char *updates[] = {
3300  "DROP TABLE IF EXISTS bdbookmark;",
3301  "CREATE TABLE bdbookmark ("
3302  " serialid varchar(40) NOT NULL DEFAULT '',"
3303  " `name` varchar(128) DEFAULT NULL,"
3304  " bdstate varchar(4096) NOT NULL DEFAULT '',"
3305  " `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
3306  " PRIMARY KEY (serialid)"
3307  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3308 
3309  // #12612 strip \0 characters from channel/channelscan_channel callsign and name
3310  "UPDATE channel SET callsign=REPLACE(callsign,'\\0',''),"
3311  "name=REPLACE(name,'\\0','');",
3312 
3313  // "BackendWSPort" was removed in caaaeef8166722888012f4ecaf3e9b0f09df512a
3314  "DELETE FROM settings WHERE value='BackendWSPort';",
3315  nullptr
3316  };
3317 
3318  if (!performActualUpdate(&updates[0], "1344", dbver))
3319  return false;
3320  }
3321 
3322  if (dbver == "1344")
3323  {
3324  const char *updates[] = {
3325  "ALTER TABLE capturecard ADD COLUMN "
3326  " reclimit INT UNSIGNED DEFAULT 1 NOT NULL",
3327  "UPDATE capturecard cc, "
3328  " ( SELECT IF(parentid>0, parentid, cardid) cardid, "
3329  " count(*) cnt "
3330  " FROM capturecard "
3331  " GROUP BY if(parentid>0, parentid, cardid) "
3332  " ) p "
3333  "SET cc.reclimit = p.cnt "
3334  "WHERE cc.cardid = p.cardid OR cc.parentid = p.cardid",
3335  nullptr
3336  };
3337 
3338  if (!performActualUpdate(&updates[0], "1345", dbver))
3339  return false;
3340  }
3341 
3342  if (dbver == "1345")
3343  {
3344  const char *updates[] = {
3345  "ALTER TABLE capturecard ADD COLUMN "
3346  " schedgroup TINYINT(1) DEFAULT 0 NOT NULL",
3347  nullptr
3348  };
3349 
3350  if (!performActualUpdate(&updates[0], "1346", dbver))
3351  return false;
3352  }
3353 
3354  /*
3355  * TODO the following settings are no more, clean them up with the next schema change
3356  * to avoid confusion by stale settings in the database
3357  *
3358  * WatchTVGuide
3359  */
3360 
3361  if (dbver == "1346")
3362  {
3363  QString master;
3364  // Create new MasterServerName setting
3365  if (gCoreContext->IsMasterHost())
3366  master =
3367  "insert into settings (value,data,hostname) "
3368  "values('MasterServerName','"
3369  + gCoreContext->GetHostName() + "', null);";
3370  else
3371  master =
3372  "insert into settings (value,data,hostname) "
3373  "select 'MasterServerName', b.hostname, null "
3374  "from settings a, settings b "
3375  "where a.value = 'MasterServerIP' "
3376  "and b.value in ('BackendServerIP','BackendServerIP6')"
3377  "and a.data = b.data;";
3378 
3379  const char *updates[] = {
3380  // Create new MasterServerName setting
3381  master.toLocal8Bit().constData(),
3382  // Create new BackendServerAddr setting for each backend server
3383  // Assume using IPV4 value.
3384  "insert into settings (value,data,hostname) "
3385  "select 'BackendServerAddr', data,hostname from settings "
3386  "where value = 'BackendServerIP';",
3387  // Update BackendServerAddr setting for cases where IPV6 is used
3388  "update settings a, settings b "
3389  "set b.data = a.data "
3390  "where a.value = 'BackendServerIP6' "
3391  "and b.hostname = a.hostname "
3392  "and b.value = 'BackendServerAddr' "
3393  "and b.data = '127.0.0.1' "
3394  "and a.data != '::1' "
3395  "and a.data is not null "
3396  "and a.data != ''; ",
3397  // Update BackendServerAddr setting for master backend to
3398  // conform to MasterServerIP setting
3399  "update settings a, settings b, settings c "
3400  "set c.data = a.data "
3401  "where a.value = 'MasterServerIP' " // 1 row
3402  "and b.value = 'MasterServerName' " // 1 row
3403  "and c.value = 'BackendServerAddr' " // 1 row per BE
3404  "and c.hostname = b.data;", // restrict to master
3405  // Delete obsolete settings
3406  "delete from settings "
3407  "where value in ('WatchTVGuide');",
3408  nullptr
3409  };
3410 
3411  if (!performActualUpdate(&updates[0], "1347", dbver))
3412  return false;
3413  }
3414 
3415  if (dbver == "1347")
3416  {
3417  const char *updates[] = {
3418  "ALTER TABLE record MODIFY COLUMN startdate DATE DEFAULT NULL",
3419  "ALTER TABLE record MODIFY COLUMN enddate DATE DEFAULT NULL",
3420  "ALTER TABLE record MODIFY COLUMN starttime TIME DEFAULT NULL",
3421  "ALTER TABLE record MODIFY COLUMN endtime TIME DEFAULT NULL",
3422  nullptr
3423  };
3424  if (!performActualUpdate(updates, "1348", dbver))
3425  return false;
3426  }
3427 
3428  if (dbver == "1348")
3429  {
3430  const char *updates[] = {
3431  "update capturecard "
3432  " set videodevice=left(videodevice, "
3433  " locate('-', videodevice)-1) "
3434  " where cardtype='HDHOMERUN' "
3435  " and videodevice like '%-%'",
3436  nullptr
3437  };
3438  if (!performActualUpdate(updates, "1349", dbver))
3439  return false;
3440  }
3441 
3442  if (dbver == "1349")
3443  {
3444  const char *updates[] = {
3445  // Incorrect DB update removed
3446  nullptr
3447  };
3448  if (!performActualUpdate(updates, "1350", dbver))
3449  return false;
3450  }
3451 
3452  return true;
3453 }
3454 
3474 {
3475  MSqlQuery query(MSqlQuery::InitCon());
3476  query.prepare("SHOW TABLES;");
3477 
3478  // check for > 1 table here since the schemalock table should exist
3479  if (query.exec() && query.isActive() && query.size() > 1)
3480  {
3481  QString msg = QString(
3482  "Told to create a NEW database schema, but the database\n"
3483  "already has %1 tables.\n"
3484  "If you are sure this is a good MythTV database, verify\n"
3485  "that the settings table has the DBSchemaVer variable.\n")
3486  .arg(query.size() - 1);
3487  LOG(VB_GENERAL, LOG_ERR, msg);
3488  return false;
3489  }
3490 
3491  LOG(VB_GENERAL, LOG_NOTICE,
3492  "Inserting MythTV initial database information.");
3493 
3494  const char *updates[] = {
3495 "CREATE TABLE capturecard ("
3496 " cardid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3497 " videodevice varchar(128) DEFAULT NULL,"
3498 " audiodevice varchar(128) DEFAULT NULL,"
3499 " vbidevice varchar(128) DEFAULT NULL,"
3500 " cardtype varchar(32) DEFAULT 'V4L',"
3501 " defaultinput varchar(32) DEFAULT 'Television',"
3502 " audioratelimit int(11) DEFAULT NULL,"
3503 " hostname varchar(64) DEFAULT NULL,"
3504 " dvb_swfilter int(11) DEFAULT '0',"
3505 " dvb_sat_type int(11) NOT NULL DEFAULT '0',"
3506 " dvb_wait_for_seqstart int(11) NOT NULL DEFAULT '1',"
3507 " skipbtaudio tinyint(1) DEFAULT '0',"
3508 " dvb_on_demand tinyint(4) NOT NULL DEFAULT '0',"
3509 " dvb_diseqc_type smallint(6) DEFAULT NULL,"
3510 " firewire_speed int(10) unsigned NOT NULL DEFAULT '0',"
3511 " firewire_model varchar(32) DEFAULT NULL,"
3512 " firewire_connection int(10) unsigned NOT NULL DEFAULT '0',"
3513 " signal_timeout int(11) NOT NULL DEFAULT '1000',"
3514 " channel_timeout int(11) NOT NULL DEFAULT '3000',"
3515 " dvb_tuning_delay int(10) unsigned NOT NULL DEFAULT '0',"
3516 " contrast int(11) NOT NULL DEFAULT '0',"
3517 " brightness int(11) NOT NULL DEFAULT '0',"
3518 " colour int(11) NOT NULL DEFAULT '0',"
3519 " hue int(11) NOT NULL DEFAULT '0',"
3520 " diseqcid int(10) unsigned DEFAULT NULL,"
3521 " dvb_eitscan tinyint(1) NOT NULL DEFAULT '1',"
3522 " PRIMARY KEY (cardid)"
3523 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3524 "CREATE TABLE cardinput ("
3525 " cardinputid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3526 " cardid int(10) unsigned NOT NULL DEFAULT '0',"
3527 " sourceid int(10) unsigned NOT NULL DEFAULT '0',"
3528 " inputname varchar(32) NOT NULL DEFAULT '',"
3529 " externalcommand varchar(128) DEFAULT NULL,"
3530 " changer_device varchar(128) DEFAULT NULL,"
3531 " changer_model varchar(128) DEFAULT NULL,"
3532 " tunechan varchar(10) DEFAULT NULL,"
3533 " startchan varchar(10) DEFAULT NULL,"
3534 " displayname varchar(64) NOT NULL DEFAULT '',"
3535 " dishnet_eit tinyint(1) NOT NULL DEFAULT '0',"
3536 " recpriority int(11) NOT NULL DEFAULT '0',"
3537 " quicktune tinyint(4) NOT NULL DEFAULT '0',"
3538 " schedorder int(10) unsigned NOT NULL DEFAULT '0',"
3539 " livetvorder int(10) unsigned NOT NULL DEFAULT '0',"
3540 " PRIMARY KEY (cardinputid)"
3541 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3542 "CREATE TABLE channel ("
3543 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
3544 " channum varchar(10) NOT NULL DEFAULT '',"
3545 " freqid varchar(10) DEFAULT NULL,"
3546 " sourceid int(10) unsigned DEFAULT NULL,"
3547 " callsign varchar(20) NOT NULL DEFAULT '',"
3548 " `name` varchar(64) NOT NULL DEFAULT '',"
3549 " icon varchar(255) NOT NULL DEFAULT '',"
3550 " finetune int(11) DEFAULT NULL,"
3551 " videofilters varchar(255) NOT NULL DEFAULT '',"
3552 " xmltvid varchar(255) NOT NULL DEFAULT '',"
3553 " recpriority int(10) NOT NULL DEFAULT '0',"
3554 " contrast int(11) DEFAULT '32768',"
3555 " brightness int(11) DEFAULT '32768',"
3556 " colour int(11) DEFAULT '32768',"
3557 " hue int(11) DEFAULT '32768',"
3558 " tvformat varchar(10) NOT NULL DEFAULT 'Default',"
3559 " visible tinyint(1) NOT NULL DEFAULT '1',"
3560 " outputfilters varchar(255) NOT NULL DEFAULT '',"
3561 " useonairguide tinyint(1) DEFAULT '0',"
3562 " mplexid smallint(6) DEFAULT NULL,"
3563 " serviceid mediumint(8) unsigned DEFAULT NULL,"
3564 " tmoffset int(11) NOT NULL DEFAULT '0',"
3565 " atsc_major_chan int(10) unsigned NOT NULL DEFAULT '0',"
3566 " atsc_minor_chan int(10) unsigned NOT NULL DEFAULT '0',"
3567 " last_record datetime NOT NULL,"
3568 " default_authority varchar(32) NOT NULL DEFAULT '',"
3569 " commmethod int(11) NOT NULL DEFAULT '-1',"
3570 " iptvid smallint(6) unsigned DEFAULT NULL,"
3571 " PRIMARY KEY (chanid),"
3572 " KEY channel_src (channum,sourceid),"
3573 " KEY sourceid (sourceid,xmltvid,chanid),"
3574 " KEY visible (visible)"
3575 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3576 "CREATE TABLE channelgroup ("
3577 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
3578 " chanid int(11) unsigned NOT NULL DEFAULT '0',"
3579 " grpid int(11) NOT NULL DEFAULT '1',"
3580 " PRIMARY KEY (id)"
3581 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3582 "CREATE TABLE channelgroupnames ("
3583 " grpid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3584 " `name` varchar(64) NOT NULL DEFAULT '0',"
3585 " PRIMARY KEY (grpid)"
3586 ") ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;",
3587 "CREATE TABLE channelscan ("
3588 " scanid int(3) unsigned NOT NULL AUTO_INCREMENT,"
3589 " cardid int(3) unsigned NOT NULL,"
3590 " sourceid int(3) unsigned NOT NULL,"
3591 " processed tinyint(1) unsigned NOT NULL,"
3592 " scandate datetime NOT NULL,"
3593 " PRIMARY KEY (scanid)"
3594 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3595 "CREATE TABLE channelscan_channel ("
3596 " transportid int(6) unsigned NOT NULL,"
3597 " scanid int(3) unsigned NOT NULL,"
3598 " mplex_id smallint(6) NOT NULL,"
3599 " source_id int(3) unsigned NOT NULL,"
3600 " channel_id int(3) unsigned NOT NULL DEFAULT '0',"
3601 " callsign varchar(20) NOT NULL DEFAULT '',"
3602 " service_name varchar(64) NOT NULL DEFAULT '',"
3603 " chan_num varchar(10) NOT NULL DEFAULT '',"
3604 " service_id mediumint(8) unsigned NOT NULL DEFAULT '0',"
3605 " atsc_major_channel int(4) unsigned NOT NULL DEFAULT '0',"
3606 " atsc_minor_channel int(4) unsigned NOT NULL DEFAULT '0',"
3607 " use_on_air_guide tinyint(1) NOT NULL DEFAULT '0',"
3608 " hidden tinyint(1) NOT NULL DEFAULT '0',"
3609 " hidden_in_guide tinyint(1) NOT NULL DEFAULT '0',"
3610 " freqid varchar(10) NOT NULL DEFAULT '',"
3611 " icon varchar(255) NOT NULL DEFAULT '',"
3612 " tvformat varchar(10) NOT NULL DEFAULT 'Default',"
3613 " xmltvid varchar(64) NOT NULL DEFAULT '',"
3614 " pat_tsid int(5) unsigned NOT NULL DEFAULT '0',"
3615 " vct_tsid int(5) unsigned NOT NULL DEFAULT '0',"
3616 " vct_chan_tsid int(5) unsigned NOT NULL DEFAULT '0',"
3617 " sdt_tsid int(5) unsigned NOT NULL DEFAULT '0',"
3618 " orig_netid int(5) unsigned NOT NULL DEFAULT '0',"
3619 " netid int(5) unsigned NOT NULL DEFAULT '0',"
3620 " si_standard varchar(10) NOT NULL,"
3621 " in_channels_conf tinyint(1) unsigned NOT NULL DEFAULT '0',"
3622 " in_pat tinyint(1) unsigned NOT NULL DEFAULT '0',"
3623 " in_pmt tinyint(1) unsigned NOT NULL DEFAULT '0',"
3624 " in_vct tinyint(1) unsigned NOT NULL DEFAULT '0',"
3625 " in_nit tinyint(1) unsigned NOT NULL DEFAULT '0',"
3626 " in_sdt tinyint(1) unsigned NOT NULL DEFAULT '0',"
3627 " is_encrypted tinyint(1) unsigned NOT NULL DEFAULT '0',"
3628 " is_data_service tinyint(1) unsigned NOT NULL DEFAULT '0',"
3629 " is_audio_service tinyint(1) unsigned NOT NULL DEFAULT '0',"
3630 " is_opencable tinyint(1) unsigned NOT NULL DEFAULT '0',"
3631 " could_be_opencable tinyint(1) unsigned NOT NULL DEFAULT '0',"
3632 " decryption_status smallint(2) unsigned NOT NULL DEFAULT '0',"
3633 " default_authority varchar(32) NOT NULL DEFAULT ''"
3634 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3635 "CREATE TABLE channelscan_dtv_multiplex ("
3636 " transportid int(6) unsigned NOT NULL AUTO_INCREMENT,"
3637 " scanid int(3) unsigned NOT NULL,"
3638 " mplexid smallint(6) unsigned NOT NULL,"
3639 " frequency bigint(12) unsigned NOT NULL,"
3640 " inversion char(1) NOT NULL DEFAULT 'a',"
3641 " symbolrate bigint(12) unsigned NOT NULL DEFAULT '0',"
3642 " fec varchar(10) NOT NULL DEFAULT 'auto',"
3643 " polarity char(1) NOT NULL DEFAULT '',"
3644 " hp_code_rate varchar(10) NOT NULL DEFAULT 'auto',"
3645 " mod_sys varchar(10) DEFAULT NULL,"
3646 " rolloff varchar(4) DEFAULT NULL,"
3647 " lp_code_rate varchar(10) NOT NULL DEFAULT 'auto',"
3648 " modulation varchar(10) NOT NULL DEFAULT 'auto',"
3649 " transmission_mode char(1) NOT NULL DEFAULT 'a',"
3650 " guard_interval varchar(10) NOT NULL DEFAULT 'auto',"
3651 " hierarchy varchar(10) NOT NULL DEFAULT 'auto',"
3652 " bandwidth char(1) NOT NULL DEFAULT 'a',"
3653 " sistandard varchar(10) NOT NULL,"
3654 " tuner_type smallint(2) unsigned NOT NULL,"
3655 " default_authority varchar(32) NOT NULL DEFAULT '',"
3656 " PRIMARY KEY (transportid)"
3657 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3658 "CREATE TABLE codecparams ("
3659 " `profile` int(10) unsigned NOT NULL DEFAULT '0',"
3660 " `name` varchar(128) NOT NULL DEFAULT '',"
3661 " `value` varchar(128) DEFAULT NULL,"
3662 " PRIMARY KEY (`profile`,`name`)"
3663 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3664 "CREATE TABLE credits ("
3665 " person mediumint(8) unsigned NOT NULL DEFAULT '0',"
3666 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
3667 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3668 " role set('actor','director','producer','executive_producer','writer','guest_star','host','adapter','presenter','commentator','guest') NOT NULL DEFAULT '',"
3669 " UNIQUE KEY chanid (chanid,starttime,person,role),"
3670 " KEY person (person,role)"
3671 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3672 "CREATE TABLE customexample ("
3673 " rulename varchar(64) NOT NULL,"
3674 " fromclause varchar(10000) NOT NULL DEFAULT '',"
3675 " whereclause varchar(10000) NOT NULL DEFAULT '',"
3676 " search tinyint(4) NOT NULL DEFAULT '0',"
3677 " PRIMARY KEY (rulename)"
3678 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3679 "CREATE TABLE diseqc_config ("
3680 " cardinputid int(10) unsigned NOT NULL,"
3681 " diseqcid int(10) unsigned NOT NULL,"
3682 " `value` varchar(16) NOT NULL DEFAULT '',"
3683 " KEY id (cardinputid)"
3684 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3685 "CREATE TABLE diseqc_tree ("
3686 " diseqcid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3687 " parentid int(10) unsigned DEFAULT NULL,"
3688 " ordinal tinyint(3) unsigned NOT NULL,"
3689 " `type` varchar(16) NOT NULL DEFAULT '',"
3690 " subtype varchar(16) NOT NULL DEFAULT '',"
3691 " description varchar(32) NOT NULL DEFAULT '',"
3692 " switch_ports tinyint(3) unsigned NOT NULL DEFAULT '0',"
3693 " rotor_hi_speed float NOT NULL DEFAULT '0',"
3694 " rotor_lo_speed float NOT NULL DEFAULT '0',"
3695 " rotor_positions varchar(255) NOT NULL DEFAULT '',"
3696 " lnb_lof_switch int(10) NOT NULL DEFAULT '0',"
3697 " lnb_lof_hi int(10) NOT NULL DEFAULT '0',"
3698 " lnb_lof_lo int(10) NOT NULL DEFAULT '0',"
3699 " cmd_repeat int(11) NOT NULL DEFAULT '1',"
3700 " lnb_pol_inv tinyint(4) NOT NULL DEFAULT '0',"
3701 " address tinyint(3) unsigned NOT NULL DEFAULT '0',"
3702 " PRIMARY KEY (diseqcid),"
3703 " KEY parentid (parentid)"
3704 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3705 "CREATE TABLE displayprofilegroups ("
3706 " `name` varchar(128) NOT NULL,"
3707 " hostname varchar(64) NOT NULL,"
3708 " profilegroupid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3709 " PRIMARY KEY (`name`,hostname),"
3710 " UNIQUE KEY profilegroupid (profilegroupid)"
3711 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3712 "CREATE TABLE displayprofiles ("
3713 " profilegroupid int(10) unsigned NOT NULL,"
3714 " profileid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3715 " `value` varchar(128) NOT NULL,"
3716 " `data` varchar(255) NOT NULL DEFAULT '',"
3717 " KEY profilegroupid (profilegroupid),"
3718 " KEY profileid (profileid,`value`),"
3719 " KEY profileid_2 (profileid)"
3720 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3721 "CREATE TABLE dtv_multiplex ("
3722 " mplexid smallint(6) NOT NULL AUTO_INCREMENT,"
3723 " sourceid smallint(6) DEFAULT NULL,"
3724 " transportid int(11) DEFAULT NULL,"
3725 " networkid int(11) DEFAULT NULL,"
3726 " frequency int(11) DEFAULT NULL,"
3727 " inversion char(1) DEFAULT 'a',"
3728 " symbolrate int(11) DEFAULT NULL,"
3729 " fec varchar(10) DEFAULT 'auto',"
3730 " polarity char(1) DEFAULT NULL,"
3731 " modulation varchar(10) DEFAULT 'auto',"
3732 " bandwidth char(1) DEFAULT 'a',"
3733 " lp_code_rate varchar(10) DEFAULT 'auto',"
3734 " transmission_mode char(1) DEFAULT 'a',"
3735 " guard_interval varchar(10) DEFAULT 'auto',"
3736 " visible smallint(1) NOT NULL DEFAULT '0',"
3737 " constellation varchar(10) DEFAULT 'auto',"
3738 " hierarchy varchar(10) DEFAULT 'auto',"
3739 " hp_code_rate varchar(10) DEFAULT 'auto',"
3740 " mod_sys varchar(10) DEFAULT NULL,"
3741 " rolloff varchar(4) DEFAULT NULL,"
3742 " sistandard varchar(10) DEFAULT 'dvb',"
3743 " serviceversion smallint(6) DEFAULT '33',"
3744 " updatetimestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
3745 " default_authority varchar(32) NOT NULL DEFAULT '',"
3746 " PRIMARY KEY (mplexid)"
3747 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3748 "CREATE TABLE dtv_privatetypes ("
3749 " sitype varchar(4) NOT NULL DEFAULT '',"
3750 " networkid int(11) NOT NULL DEFAULT '0',"
3751 " private_type varchar(20) NOT NULL DEFAULT '',"
3752 " private_value varchar(100) NOT NULL DEFAULT ''"
3753 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3754 "CREATE TABLE dvdbookmark ("
3755 " serialid varchar(16) NOT NULL DEFAULT '',"
3756 " `name` varchar(32) DEFAULT NULL,"
3757 " title smallint(6) NOT NULL DEFAULT '0',"
3758 " audionum tinyint(4) NOT NULL DEFAULT '-1',"
3759 " subtitlenum tinyint(4) NOT NULL DEFAULT '-1',"
3760 " framenum bigint(20) NOT NULL DEFAULT '0',"
3761 " `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
3762 " PRIMARY KEY (serialid)"
3763 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3764 "CREATE TABLE dvdinput ("
3765 " intid int(10) unsigned NOT NULL,"
3766 " hsize int(10) unsigned DEFAULT NULL,"
3767 " vsize int(10) unsigned DEFAULT NULL,"
3768 " ar_num int(10) unsigned DEFAULT NULL,"
3769 " ar_denom int(10) unsigned DEFAULT NULL,"
3770 " fr_code int(10) unsigned DEFAULT NULL,"
3771 " letterbox tinyint(1) DEFAULT NULL,"
3772 " v_format varchar(16) DEFAULT NULL,"
3773 " PRIMARY KEY (intid)"
3774 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3775 "CREATE TABLE dvdtranscode ("
3776 " intid int(11) NOT NULL AUTO_INCREMENT,"
3777 " input int(10) unsigned DEFAULT NULL,"
3778 " `name` varchar(128) NOT NULL,"
3779 " sync_mode int(10) unsigned DEFAULT NULL,"
3780 " use_yv12 tinyint(1) DEFAULT NULL,"
3781 " cliptop int(11) DEFAULT NULL,"
3782 " clipbottom int(11) DEFAULT NULL,"
3783 " clipleft int(11) DEFAULT NULL,"
3784 " clipright int(11) DEFAULT NULL,"
3785 " f_resize_h int(11) DEFAULT NULL,"
3786 " f_resize_w int(11) DEFAULT NULL,"
3787 " hq_resize_h int(11) DEFAULT NULL,"
3788 " hq_resize_w int(11) DEFAULT NULL,"
3789 " grow_h int(11) DEFAULT NULL,"
3790 " grow_w int(11) DEFAULT NULL,"
3791 " clip2top int(11) DEFAULT NULL,"
3792 " clip2bottom int(11) DEFAULT NULL,"
3793 " clip2left int(11) DEFAULT NULL,"
3794 " clip2right int(11) DEFAULT NULL,"
3795 " codec varchar(128) NOT NULL,"
3796 " codec_param varchar(128) DEFAULT NULL,"
3797 " bitrate int(11) DEFAULT NULL,"
3798 " a_sample_r int(11) DEFAULT NULL,"
3799 " a_bitrate int(11) DEFAULT NULL,"
3800 " two_pass tinyint(1) DEFAULT NULL,"
3801 " tc_param varchar(128) DEFAULT NULL,"
3802 " PRIMARY KEY (intid)"
3803 ") ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;",
3804 "CREATE TABLE eit_cache ("
3805 " chanid int(10) NOT NULL,"
3806 " eventid int(10) unsigned NOT NULL DEFAULT '0',"
3807 " tableid tinyint(3) unsigned NOT NULL,"
3808 " version tinyint(3) unsigned NOT NULL,"
3809 " endtime int(10) unsigned NOT NULL,"
3810 " `status` tinyint(4) NOT NULL DEFAULT '0',"
3811 " PRIMARY KEY (chanid,eventid,`status`)"
3812 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3813 "CREATE TABLE filemarkup ("
3814 " filename text NOT NULL,"
3815 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
3816 " `offset` bigint(20) unsigned DEFAULT NULL,"
3817 " `type` tinyint(4) NOT NULL DEFAULT '0',"
3818 " KEY filename (filename(255))"
3819 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3820 "CREATE TABLE housekeeping ("
3821 " tag varchar(64) NOT NULL DEFAULT '',"
3822 " lastrun datetime DEFAULT NULL,"
3823 " PRIMARY KEY (tag)"
3824 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3825 "CREATE TABLE inputgroup ("
3826 " cardinputid int(10) unsigned NOT NULL,"
3827 " inputgroupid int(10) unsigned NOT NULL,"
3828 " inputgroupname varchar(32) NOT NULL"
3829 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3830 "CREATE TABLE internetcontent ("
3831 " `name` varchar(255) NOT NULL,"
3832 " thumbnail varchar(255) DEFAULT NULL,"
3833 " `type` smallint(3) NOT NULL,"
3834 " author varchar(128) NOT NULL,"
3835 " description text NOT NULL,"
3836 " commandline text NOT NULL,"
3837 " version double NOT NULL,"
3838 " updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3839 " search tinyint(1) NOT NULL,"
3840 " tree tinyint(1) NOT NULL,"
3841 " podcast tinyint(1) NOT NULL,"
3842 " download tinyint(1) NOT NULL,"
3843 " `host` varchar(128) DEFAULT NULL"
3844 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3845 "CREATE TABLE internetcontentarticles ("
3846 " feedtitle varchar(255) NOT NULL,"
3847 " path text NOT NULL,"
3848 " paththumb text NOT NULL,"
3849 " title varchar(255) NOT NULL,"
3850 " subtitle varchar(255) NOT NULL,"
3851 " season smallint(5) NOT NULL DEFAULT '0',"
3852 " episode smallint(5) NOT NULL DEFAULT '0',"
3853 " description text NOT NULL,"
3854 " url text NOT NULL,"
3855 " `type` smallint(3) NOT NULL,"
3856 " thumbnail text NOT NULL,"
3857 " mediaURL text NOT NULL,"
3858 " author varchar(255) NOT NULL,"
3859 " `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3860 " `time` int(11) NOT NULL,"
3861 " rating varchar(255) NOT NULL,"
3862 " filesize bigint(20) NOT NULL,"
3863 " player varchar(255) NOT NULL,"
3864 " playerargs text NOT NULL,"
3865 " download varchar(255) NOT NULL,"
3866 " downloadargs text NOT NULL,"
3867 " width smallint(6) NOT NULL,"
3868 " height smallint(6) NOT NULL,"
3869 " `language` varchar(128) NOT NULL,"
3870 " podcast tinyint(1) NOT NULL,"
3871 " downloadable tinyint(1) NOT NULL,"
3872 " customhtml tinyint(1) NOT NULL,"
3873 " countries varchar(255) NOT NULL"
3874 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3875 "CREATE TABLE inuseprograms ("
3876 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
3877 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3878 " recusage varchar(128) NOT NULL DEFAULT '',"
3879 " lastupdatetime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3880 " hostname varchar(64) NOT NULL DEFAULT '',"
3881 " rechost varchar(64) NOT NULL,"
3882 " recdir varchar(255) NOT NULL DEFAULT '',"
3883 " KEY chanid (chanid,starttime),"
3884 " KEY recusage (recusage,lastupdatetime)"
3885 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3886 "CREATE TABLE iptv_channel ("
3887 " iptvid smallint(6) unsigned NOT NULL AUTO_INCREMENT,"
3888 " chanid int(10) unsigned NOT NULL,"
3889 " url text NOT NULL,"
3890 " `type` set('data','rfc2733-1','rfc2733-2','rfc5109-1','rfc5109-2','smpte2022-1','smpte2022-2') DEFAULT NULL,"
3891 " bitrate int(10) unsigned NOT NULL,"
3892 " PRIMARY KEY (iptvid)"
3893 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3894 "CREATE TABLE jobqueue ("
3895 " id int(11) NOT NULL AUTO_INCREMENT,"
3896 " chanid int(10) NOT NULL DEFAULT '0',"
3897 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3898 " inserttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3899 " `type` int(11) NOT NULL DEFAULT '0',"
3900 " cmds int(11) NOT NULL DEFAULT '0',"
3901 " flags int(11) NOT NULL DEFAULT '0',"
3902 " `status` int(11) NOT NULL DEFAULT '0',"
3903 " statustime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
3904 " hostname varchar(64) NOT NULL DEFAULT '',"
3905 " args blob NOT NULL,"
3906 " `comment` varchar(128) NOT NULL DEFAULT '',"
3907 " schedruntime datetime NOT NULL DEFAULT '2007-01-01 00:00:00',"
3908 " PRIMARY KEY (id),"
3909 " UNIQUE KEY chanid (chanid,starttime,`type`,inserttime)"
3910 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3911 "CREATE TABLE jumppoints ("
3912 " destination varchar(128) NOT NULL DEFAULT '',"
3913 " description varchar(255) DEFAULT NULL,"
3914 " keylist varchar(128) DEFAULT NULL,"
3915 " hostname varchar(64) NOT NULL DEFAULT '',"
3916 " PRIMARY KEY (destination,hostname)"
3917 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3918 "CREATE TABLE keybindings ("
3919 " `context` varchar(32) NOT NULL DEFAULT '',"
3920 " `action` varchar(32) NOT NULL DEFAULT '',"
3921 " description varchar(255) DEFAULT NULL,"
3922 " keylist varchar(128) DEFAULT NULL,"
3923 " hostname varchar(64) NOT NULL DEFAULT '',"
3924 " PRIMARY KEY (`context`,`action`,hostname)"
3925 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3926 "CREATE TABLE keyword ("
3927 " phrase varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
3928 " searchtype int(10) unsigned NOT NULL DEFAULT '3',"
3929 " UNIQUE KEY phrase (phrase,searchtype)"
3930 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3931 "CREATE TABLE livestream ("
3932 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
3933 " width int(10) unsigned NOT NULL,"
3934 " height int(10) unsigned NOT NULL,"
3935 " bitrate int(10) unsigned NOT NULL,"
3936 " audiobitrate int(10) unsigned NOT NULL,"
3937 " samplerate int(10) unsigned NOT NULL,"
3938 " audioonlybitrate int(10) unsigned NOT NULL,"
3939 " segmentsize int(10) unsigned NOT NULL DEFAULT '10',"
3940 " maxsegments int(10) unsigned NOT NULL DEFAULT '0',"
3941 " startsegment int(10) unsigned NOT NULL DEFAULT '0',"
3942 " currentsegment int(10) unsigned NOT NULL DEFAULT '0',"
3943 " segmentcount int(10) unsigned NOT NULL DEFAULT '0',"
3944 " percentcomplete int(10) unsigned NOT NULL DEFAULT '0',"
3945 " created datetime NOT NULL,"
3946 " lastmodified datetime NOT NULL,"
3947 " relativeurl varchar(512) NOT NULL,"
3948 " fullurl varchar(1024) NOT NULL,"
3949 " `status` int(10) unsigned NOT NULL DEFAULT '0',"
3950 " statusmessage varchar(256) NOT NULL,"
3951 " sourcefile varchar(512) NOT NULL,"
3952 " sourcehost varchar(64) NOT NULL,"
3953 " sourcewidth int(10) unsigned NOT NULL DEFAULT '0',"
3954 " sourceheight int(10) unsigned NOT NULL DEFAULT '0',"
3955 " outdir varchar(256) NOT NULL,"
3956 " outbase varchar(128) NOT NULL,"
3957 " PRIMARY KEY (id)"
3958 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3959 "CREATE TABLE logging ("
3960 " id bigint(20) unsigned NOT NULL AUTO_INCREMENT,"
3961 " `host` varchar(64) NOT NULL DEFAULT '',"
3962 " application varchar(64) NOT NULL DEFAULT '',"
3963 " pid int(11) NOT NULL DEFAULT '0',"
3964 " tid int(11) NOT NULL DEFAULT '0',"
3965 " thread varchar(64) NOT NULL DEFAULT '',"
3966 " filename varchar(255) NOT NULL DEFAULT '',"
3967 " line int(11) NOT NULL DEFAULT '0',"
3968 " `function` varchar(255) NOT NULL DEFAULT '',"
3969 " msgtime datetime NOT NULL,"
3970 " `level` int(11) NOT NULL DEFAULT '0',"
3971 " message varchar(2048) NOT NULL,"
3972 " PRIMARY KEY (id),"
3973 " KEY `host` (`host`,application,pid,msgtime),"
3974 " KEY msgtime (msgtime),"
3975 " KEY `level` (`level`)"
3976 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3977 "CREATE TABLE mythlog ("
3978 " logid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3979 " module varchar(32) NOT NULL DEFAULT '',"
3980 " priority int(11) NOT NULL DEFAULT '0',"
3981 " acknowledged tinyint(1) DEFAULT '0',"
3982 " logdate datetime DEFAULT NULL,"
3983 " `host` varchar(128) DEFAULT NULL,"
3984 " message varchar(255) NOT NULL DEFAULT '',"
3985 " details varchar(16000) NOT NULL DEFAULT '',"
3986 " PRIMARY KEY (logid),"
3987 " KEY module (module)"
3988 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3989 "CREATE TABLE oldfind ("
3990 " recordid int(11) NOT NULL DEFAULT '0',"
3991 " findid int(11) NOT NULL DEFAULT '0',"
3992 " PRIMARY KEY (recordid,findid)"
3993 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3994 "CREATE TABLE oldprogram ("
3995 " oldtitle varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
3996 " airdate datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3997 " PRIMARY KEY (oldtitle)"
3998 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3999 "CREATE TABLE oldrecorded ("
4000 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4001 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4002 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4003 " title varchar(128) NOT NULL DEFAULT '',"
4004 " subtitle varchar(128) NOT NULL DEFAULT '',"
4005 " description varchar(16000) NOT NULL DEFAULT '',"
4006 " season smallint(5) NOT NULL,"
4007 " episode smallint(5) NOT NULL,"
4008 " category varchar(64) NOT NULL DEFAULT '',"
4009 " seriesid varchar(40) NOT NULL DEFAULT '',"
4010 " programid varchar(40) NOT NULL DEFAULT '',"
4011 " inetref varchar(40) NOT NULL,"
4012 " findid int(11) NOT NULL DEFAULT '0',"
4013 " recordid int(11) NOT NULL DEFAULT '0',"
4014 " station varchar(20) NOT NULL DEFAULT '',"
4015 " rectype int(10) unsigned NOT NULL DEFAULT '0',"
4016 " `duplicate` tinyint(1) NOT NULL DEFAULT '0',"
4017 " recstatus int(11) NOT NULL DEFAULT '0',"
4018 " reactivate smallint(6) NOT NULL DEFAULT '0',"
4019 " generic tinyint(1) NOT NULL,"
4020 " future tinyint(1) NOT NULL DEFAULT '0',"
4021 " PRIMARY KEY (station,starttime,title),"
4022 " KEY endtime (endtime),"
4023 " KEY title (title),"
4024 " KEY seriesid (seriesid),"
4025 " KEY programid (programid),"
4026 " KEY recordid (recordid),"
4027 " KEY recstatus (recstatus,programid,seriesid),"
4028 " KEY recstatus_2 (recstatus,title,subtitle),"
4029 " KEY future (future),"
4030 " KEY chanid (chanid,starttime),"
4031 " KEY subtitle (subtitle),"
4032 " KEY description (description(255))"
4033 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4034 "CREATE TABLE people ("
4035 " person mediumint(8) unsigned NOT NULL AUTO_INCREMENT,"
4036 " `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4037 " PRIMARY KEY (person),"
4038 " UNIQUE KEY `name` (`name`(41))"
4039 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4040 "CREATE TABLE pidcache ("
4041 " chanid smallint(6) NOT NULL DEFAULT '0',"
4042 " pid int(11) NOT NULL DEFAULT '-1',"
4043 " tableid int(11) NOT NULL DEFAULT '-1',"
4044 " KEY chanid (chanid)"
4045 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4046 "CREATE TABLE playgroup ("
4047 " `name` varchar(32) NOT NULL DEFAULT '',"
4048 " titlematch varchar(255) NOT NULL DEFAULT '',"
4049 " skipahead int(11) NOT NULL DEFAULT '0',"
4050 " skipback int(11) NOT NULL DEFAULT '0',"
4051 " timestretch int(11) NOT NULL DEFAULT '0',"
4052 " jump int(11) NOT NULL DEFAULT '0',"
4053 " PRIMARY KEY (`name`)"
4054 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4055 "CREATE TABLE powerpriority ("
4056 " priorityname varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,"
4057 " recpriority int(10) NOT NULL DEFAULT '0',"
4058 " selectclause varchar(16000) NOT NULL DEFAULT '',"
4059 " PRIMARY KEY (priorityname)"
4060 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4061 "CREATE TABLE profilegroups ("
4062 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4063 " `name` varchar(128) DEFAULT NULL,"
4064 " cardtype varchar(32) NOT NULL DEFAULT 'V4L',"
4065 " is_default int(1) DEFAULT '0',"
4066 " hostname varchar(64) DEFAULT NULL,"
4067 " PRIMARY KEY (id),"
4068 " UNIQUE KEY `name` (`name`,hostname),"
4069 " KEY cardtype (cardtype)"
4070 ") ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;",
4071 "CREATE TABLE program ("
4072 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4073 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4074 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4075 " title varchar(128) NOT NULL DEFAULT '',"
4076 " subtitle varchar(128) NOT NULL DEFAULT '',"
4077 " description varchar(16000) NOT NULL DEFAULT '',"
4078 " category varchar(64) NOT NULL DEFAULT '',"
4079 " category_type varchar(64) NOT NULL DEFAULT '',"
4080 " airdate year(4) NOT NULL DEFAULT '0000',"
4081 " stars float NOT NULL DEFAULT '0',"
4082 " previouslyshown tinyint(4) NOT NULL DEFAULT '0',"
4083 " title_pronounce varchar(128) NOT NULL DEFAULT '',"
4084 " stereo tinyint(1) NOT NULL DEFAULT '0',"
4085 " subtitled tinyint(1) NOT NULL DEFAULT '0',"
4086 " hdtv tinyint(1) NOT NULL DEFAULT '0',"
4087 " closecaptioned tinyint(1) NOT NULL DEFAULT '0',"
4088 " partnumber int(11) NOT NULL DEFAULT '0',"
4089 " parttotal int(11) NOT NULL DEFAULT '0',"
4090 " seriesid varchar(64) NOT NULL DEFAULT '',"
4091 " originalairdate date DEFAULT NULL,"
4092 " showtype varchar(30) NOT NULL DEFAULT '',"
4093 " colorcode varchar(20) NOT NULL DEFAULT '',"
4094 " syndicatedepisodenumber varchar(20) NOT NULL DEFAULT '',"
4095 " programid varchar(64) NOT NULL DEFAULT '',"
4096 " manualid int(10) unsigned NOT NULL DEFAULT '0',"
4097 " generic tinyint(1) DEFAULT '0',"
4098 " listingsource int(11) NOT NULL DEFAULT '0',"
4099 " `first` tinyint(1) NOT NULL DEFAULT '0',"
4100 " `last` tinyint(1) NOT NULL DEFAULT '0',"
4101 " audioprop set('STEREO','MONO','SURROUND','DOLBY','HARDHEAR','VISUALIMPAIR') NOT NULL,"
4102 " subtitletypes set('HARDHEAR','NORMAL','ONSCREEN','SIGNED') NOT NULL,"
4103 " videoprop set('HDTV','WIDESCREEN','AVC') NOT NULL,"
4104 " PRIMARY KEY (chanid,starttime,manualid),"
4105 " KEY endtime (endtime),"
4106 " KEY title (title),"
4107 " KEY title_pronounce (title_pronounce),"
4108 " KEY seriesid (seriesid),"
4109 " KEY id_start_end (chanid,starttime,endtime),"
4110 " KEY program_manualid (manualid),"
4111 " KEY previouslyshown (previouslyshown),"
4112 " KEY programid (programid,starttime),"
4113 " KEY starttime (starttime),"
4114 " KEY subtitle (subtitle),"
4115 " KEY description (description(255))"
4116 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4117 "CREATE TABLE programgenres ("
4118 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4119 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4120 " relevance char(1) NOT NULL DEFAULT '',"
4121 " genre varchar(30) DEFAULT NULL,"
4122 " PRIMARY KEY (chanid,starttime,relevance),"
4123 " KEY genre (genre)"
4124 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4125 "CREATE TABLE programrating ("
4126 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4127 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4128 " system varchar(8) DEFAULT NULL,"
4129 " rating varchar(16) DEFAULT NULL,"
4130 " UNIQUE KEY chanid (chanid,starttime,system,rating),"
4131 " KEY starttime (starttime,system)"
4132 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4133 "CREATE TABLE recgrouppassword ("
4134 " recgroup varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4135 " `password` varchar(10) NOT NULL DEFAULT '',"
4136 " PRIMARY KEY (recgroup)"
4137 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4138 "CREATE TABLE record ("
4139 " recordid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4140 " `type` int(10) unsigned NOT NULL DEFAULT '0',"
4141 " chanid int(10) unsigned DEFAULT NULL,"
4142 " starttime time NOT NULL DEFAULT '00:00:00',"
4143 " startdate date NOT NULL DEFAULT '0000-00-00',"
4144 " endtime time NOT NULL DEFAULT '00:00:00',"
4145 " enddate date NOT NULL DEFAULT '0000-00-00',"
4146 " title varchar(128) NOT NULL DEFAULT '',"
4147 " subtitle varchar(128) NOT NULL DEFAULT '',"
4148 " description varchar(16000) NOT NULL DEFAULT '',"
4149 " season smallint(5) NOT NULL,"
4150 " episode smallint(5) NOT NULL,"
4151 " category varchar(64) NOT NULL DEFAULT '',"
4152 " `profile` varchar(128) NOT NULL DEFAULT 'Default',"
4153 " recpriority int(10) NOT NULL DEFAULT '0',"
4154 " autoexpire int(11) NOT NULL DEFAULT '0',"
4155 " maxepisodes int(11) NOT NULL DEFAULT '0',"
4156 " maxnewest int(11) NOT NULL DEFAULT '0',"
4157 " startoffset int(11) NOT NULL DEFAULT '0',"
4158 " endoffset int(11) NOT NULL DEFAULT '0',"
4159 " recgroup varchar(32) NOT NULL DEFAULT 'Default',"
4160 " dupmethod int(11) NOT NULL DEFAULT '6',"
4161 " dupin int(11) NOT NULL DEFAULT '15',"
4162 " station varchar(20) NOT NULL DEFAULT '',"
4163 " seriesid varchar(40) NOT NULL DEFAULT '',"
4164 " programid varchar(40) NOT NULL DEFAULT '',"
4165 " inetref varchar(40) NOT NULL,"
4166 " search int(10) unsigned NOT NULL DEFAULT '0',"
4167 " autotranscode tinyint(1) NOT NULL DEFAULT '0',"
4168 " autocommflag tinyint(1) NOT NULL DEFAULT '0',"
4169 " autouserjob1 tinyint(1) NOT NULL DEFAULT '0',"
4170 " autouserjob2 tinyint(1) NOT NULL DEFAULT '0',"
4171 " autouserjob3 tinyint(1) NOT NULL DEFAULT '0',"
4172 " autouserjob4 tinyint(1) NOT NULL DEFAULT '0',"
4173 " autometadata tinyint(1) NOT NULL DEFAULT '0',"
4174 " findday tinyint(4) NOT NULL DEFAULT '0',"
4175 " findtime time NOT NULL DEFAULT '00:00:00',"
4176 " findid int(11) NOT NULL DEFAULT '0',"
4177 " inactive tinyint(1) NOT NULL DEFAULT '0',"
4178 " parentid int(11) NOT NULL DEFAULT '0',"
4179 " transcoder int(11) NOT NULL DEFAULT '0',"
4180 " playgroup varchar(32) NOT NULL DEFAULT 'Default',"
4181 " prefinput int(10) NOT NULL DEFAULT '0',"
4182 " next_record datetime NOT NULL,"
4183 " last_record datetime NOT NULL,"
4184 " last_delete datetime NOT NULL,"
4185 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4186 " avg_delay int(11) NOT NULL DEFAULT '100',"
4187 " filter int(10) unsigned NOT NULL DEFAULT '0',"
4188 " PRIMARY KEY (recordid),"
4189 " KEY chanid (chanid,starttime),"
4190 " KEY title (title),"
4191 " KEY seriesid (seriesid),"
4192 " KEY programid (programid),"
4193 " KEY maxepisodes (maxepisodes),"
4194 " KEY search (search),"
4195 " KEY `type` (`type`)"
4196 ") ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;",
4197 "CREATE TABLE recorded ("
4198 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4199 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4200 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4201 " title varchar(128) NOT NULL DEFAULT '',"
4202 " subtitle varchar(128) NOT NULL DEFAULT '',"
4203 " description varchar(16000) NOT NULL DEFAULT '',"
4204 " season smallint(5) NOT NULL,"
4205 " episode smallint(5) NOT NULL,"
4206 " category varchar(64) NOT NULL DEFAULT '',"
4207 " hostname varchar(64) NOT NULL DEFAULT '',"
4208 " bookmark tinyint(1) NOT NULL DEFAULT '0',"
4209 " editing int(10) unsigned NOT NULL DEFAULT '0',"
4210 " cutlist tinyint(1) NOT NULL DEFAULT '0',"
4211 " autoexpire int(11) NOT NULL DEFAULT '0',"
4212 " commflagged int(10) unsigned NOT NULL DEFAULT '0',"
4213 " recgroup varchar(32) NOT NULL DEFAULT 'Default',"
4214 " recordid int(11) DEFAULT NULL,"
4215 " seriesid varchar(40) NOT NULL DEFAULT '',"
4216 " programid varchar(40) NOT NULL DEFAULT '',"
4217 " inetref varchar(40) NOT NULL,"
4218 " lastmodified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4219 " filesize bigint(20) NOT NULL DEFAULT '0',"
4220 " stars float NOT NULL DEFAULT '0',"
4221 " previouslyshown tinyint(1) DEFAULT '0',"
4222 " originalairdate date DEFAULT NULL,"
4223 " `preserve` tinyint(1) NOT NULL DEFAULT '0',"
4224 " findid int(11) NOT NULL DEFAULT '0',"
4225 " deletepending tinyint(1) NOT NULL DEFAULT '0',"
4226 " transcoder int(11) NOT NULL DEFAULT '0',"
4227 " timestretch float NOT NULL DEFAULT '1',"
4228 " recpriority int(11) NOT NULL DEFAULT '0',"
4229 " basename varchar(255) NOT NULL,"
4230 " progstart datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4231 " progend datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4232 " playgroup varchar(32) NOT NULL DEFAULT 'Default',"
4233 " `profile` varchar(32) NOT NULL DEFAULT '',"
4234 " `duplicate` tinyint(1) NOT NULL DEFAULT '0',"
4235 " transcoded tinyint(1) NOT NULL DEFAULT '0',"
4236 " watched tinyint(4) NOT NULL DEFAULT '0',"
4237 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4238 " bookmarkupdate timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',"
4239 " PRIMARY KEY (chanid,starttime),"
4240 " KEY endtime (endtime),"
4241 " KEY seriesid (seriesid),"
4242 " KEY programid (programid),"
4243 " KEY title (title),"
4244 " KEY recordid (recordid),"
4245 " KEY deletepending (deletepending,lastmodified),"
4246 " KEY recgroup (recgroup,endtime)"
4247 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4248 "CREATE TABLE recordedartwork ("
4249 " inetref varchar(255) NOT NULL,"
4250 " season smallint(5) NOT NULL,"
4251 " `host` text NOT NULL,"
4252 " coverart text NOT NULL,"
4253 " fanart text NOT NULL,"
4254 " banner text NOT NULL"
4255 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4256 "CREATE TABLE recordedcredits ("
4257 " person mediumint(8) unsigned NOT NULL DEFAULT '0',"
4258 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4259 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4260 " role set('actor','director','producer','executive_producer','writer','guest_star','host','adapter','presenter','commentator','guest') NOT NULL DEFAULT '',"
4261 " UNIQUE KEY chanid (chanid,starttime,person,role),"
4262 " KEY person (person,role)"
4263 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4264 "CREATE TABLE recordedfile ("
4265 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4266 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4267 " basename varchar(128) NOT NULL DEFAULT '',"
4268 " filesize bigint(20) NOT NULL DEFAULT '0',"
4269 " width smallint(5) unsigned NOT NULL DEFAULT '0',"
4270 " height smallint(5) unsigned NOT NULL DEFAULT '0',"
4271 " fps float(6,3) NOT NULL DEFAULT '0.000',"
4272 " aspect float(8,6) NOT NULL DEFAULT '0.000000',"
4273 " audio_sample_rate smallint(5) unsigned NOT NULL DEFAULT '0',"
4274 " audio_bits_per_sample smallint(5) unsigned NOT NULL DEFAULT '0',"
4275 " audio_channels tinyint(3) unsigned NOT NULL DEFAULT '0',"
4276 " audio_type varchar(255) NOT NULL DEFAULT '',"
4277 " video_type varchar(255) NOT NULL DEFAULT '',"
4278 " `comment` varchar(255) NOT NULL DEFAULT '',"
4279 " hostname varchar(64) NOT NULL,"
4280 " storagegroup varchar(32) NOT NULL,"
4281 " id int(11) NOT NULL AUTO_INCREMENT,"
4282 " PRIMARY KEY (id),"
4283 " UNIQUE KEY chanid (chanid,starttime,basename),"
4284 " KEY basename (basename)"
4285 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4286 "CREATE TABLE recordedmarkup ("
4287 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4288 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4289 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4290 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4291 " `data` int(11) unsigned DEFAULT NULL,"
4292 " PRIMARY KEY (chanid,starttime,`type`,mark)"
4293 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4294 "CREATE TABLE recordedprogram ("
4295 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4296 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4297 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4298 " title varchar(128) NOT NULL DEFAULT '',"
4299 " subtitle varchar(128) NOT NULL DEFAULT '',"
4300 " description varchar(16000) NOT NULL DEFAULT '',"
4301 " category varchar(64) NOT NULL DEFAULT '',"
4302 " category_type varchar(64) NOT NULL DEFAULT '',"
4303 " airdate year(4) NOT NULL DEFAULT '0000',"
4304 " stars float unsigned NOT NULL DEFAULT '0',"
4305 " previouslyshown tinyint(4) NOT NULL DEFAULT '0',"
4306 " title_pronounce varchar(128) NOT NULL DEFAULT '',"
4307 " stereo tinyint(1) NOT NULL DEFAULT '0',"
4308 " subtitled tinyint(1) NOT NULL DEFAULT '0',"
4309 " hdtv tinyint(1) NOT NULL DEFAULT '0',"
4310 " closecaptioned tinyint(1) NOT NULL DEFAULT '0',"
4311 " partnumber int(11) NOT NULL DEFAULT '0',"
4312 " parttotal int(11) NOT NULL DEFAULT '0',"
4313 " seriesid varchar(40) NOT NULL DEFAULT '',"
4314 " originalairdate date DEFAULT NULL,"
4315 " showtype varchar(30) NOT NULL DEFAULT '',"
4316 " colorcode varchar(20) NOT NULL DEFAULT '',"
4317 " syndicatedepisodenumber varchar(20) NOT NULL DEFAULT '',"
4318 " programid varchar(40) NOT NULL DEFAULT '',"
4319 " manualid int(10) unsigned NOT NULL DEFAULT '0',"
4320 " generic tinyint(1) DEFAULT '0',"
4321 " listingsource int(11) NOT NULL DEFAULT '0',"
4322 " `first` tinyint(1) NOT NULL DEFAULT '0',"
4323 " `last` tinyint(1) NOT NULL DEFAULT '0',"
4324 " audioprop set('STEREO','MONO','SURROUND','DOLBY','HARDHEAR','VISUALIMPAIR') NOT NULL,"
4325 " subtitletypes set('HARDHEAR','NORMAL','ONSCREEN','SIGNED') NOT NULL,"
4326 " videoprop set('HDTV','WIDESCREEN','AVC','720','1080','DAMAGED') NOT NULL,"
4327 " PRIMARY KEY (chanid,starttime,manualid),"
4328 " KEY endtime (endtime),"
4329 " KEY title (title),"
4330 " KEY title_pronounce (title_pronounce),"
4331 " KEY seriesid (seriesid),"
4332 " KEY programid (programid),"
4333 " KEY id_start_end (chanid,starttime,endtime)"
4334 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4335 "CREATE TABLE recordedrating ("
4336 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4337 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4338 " system varchar(8) DEFAULT NULL,"
4339 " rating varchar(16) DEFAULT NULL,"
4340 " UNIQUE KEY chanid (chanid,starttime,system,rating),"
4341 " KEY starttime (starttime,system)"
4342 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4343 "CREATE TABLE recordedseek ("
4344 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4345 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4346 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4347 " `offset` bigint(20) unsigned NOT NULL,"
4348 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4349 " PRIMARY KEY (chanid,starttime,`type`,mark)"
4350 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4351 "CREATE TABLE recordfilter ("
4352 " filterid int(10) unsigned NOT NULL,"
4353 " description varchar(64) DEFAULT NULL,"
4354 " clause varchar(256) DEFAULT NULL,"
4355 " newruledefault tinyint(1) DEFAULT '0',"
4356 " PRIMARY KEY (filterid)"
4357 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4358 "CREATE TABLE recordingprofiles ("
4359 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4360 " `name` varchar(128) DEFAULT NULL,"
4361 " videocodec varchar(128) DEFAULT NULL,"
4362 " audiocodec varchar(128) DEFAULT NULL,"
4363 " profilegroup int(10) unsigned NOT NULL DEFAULT '0',"
4364 " PRIMARY KEY (id),"
4365 " KEY profilegroup (profilegroup)"
4366 ") ENGINE=MyISAM AUTO_INCREMENT=70 DEFAULT CHARSET=utf8;",
4367 "CREATE TABLE recordmatch ("
4368 " recordid int(10) unsigned NOT NULL,"
4369 " chanid int(10) unsigned NOT NULL,"
4370 " starttime datetime NOT NULL,"
4371 " manualid int(10) unsigned NOT NULL,"
4372 " oldrecduplicate tinyint(1) DEFAULT NULL,"
4373 " recduplicate tinyint(1) DEFAULT NULL,"
4374 " findduplicate tinyint(1) DEFAULT NULL,"
4375 " oldrecstatus int(11) DEFAULT NULL,"
4376 " findid int(11) NOT NULL DEFAULT '0',"
4377 " UNIQUE KEY recordid (recordid,chanid,starttime),"
4378 " KEY chanid (chanid,starttime,manualid),"
4379 " KEY recordid_2 (recordid,findid)"
4380 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4381 "CREATE TABLE scannerfile ("
4382 " fileid bigint(20) unsigned NOT NULL AUTO_INCREMENT,"
4383 " filesize bigint(20) unsigned NOT NULL DEFAULT '0',"
4384 " filehash varchar(64) NOT NULL DEFAULT '',"
4385 " added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
4386 " PRIMARY KEY (fileid),"
4387 " UNIQUE KEY filehash (filehash)"
4388 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4389 "CREATE TABLE scannerpath ("
4390 " fileid bigint(20) unsigned NOT NULL,"
4391 " hostname varchar(64) NOT NULL DEFAULT 'localhost',"
4392 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4393 " filename varchar(255) NOT NULL DEFAULT '',"
4394 " PRIMARY KEY (fileid)"
4395 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4396 "CREATE TABLE settings ("
4397 " `value` varchar(128) NOT NULL DEFAULT '',"
4398 " `data` varchar(16000) NOT NULL DEFAULT '',"
4399 " hostname varchar(64) DEFAULT NULL,"
4400 " KEY `value` (`value`,hostname)"
4401 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4402 "CREATE TABLE storagegroup ("
4403 " id int(11) NOT NULL AUTO_INCREMENT,"
4404 " groupname varchar(32) NOT NULL,"
4405 " hostname varchar(64) NOT NULL DEFAULT '',"
4406 " dirname varchar(235) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4407 " PRIMARY KEY (id),"
4408 " UNIQUE KEY grouphostdir (groupname,hostname,dirname),"
4409 " KEY hostname (hostname)"
4410 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4411 "CREATE TABLE tvchain ("
4412 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4413 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4414 " chainid varchar(128) NOT NULL DEFAULT '',"
4415 " chainpos int(10) NOT NULL DEFAULT '0',"
4416 " discontinuity tinyint(1) NOT NULL DEFAULT '0',"
4417 " watching int(10) NOT NULL DEFAULT '0',"
4418 " hostprefix varchar(128) NOT NULL DEFAULT '',"
4419 " cardtype varchar(32) NOT NULL DEFAULT 'V4L',"
4420 " input varchar(32) NOT NULL DEFAULT '',"
4421 " channame varchar(32) NOT NULL DEFAULT '',"
4422 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4423 " PRIMARY KEY (chanid,starttime)"
4424 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4425 "CREATE TABLE tvosdmenu ("
4426 " osdcategory varchar(32) NOT NULL,"
4427 " livetv tinyint(4) NOT NULL DEFAULT '0',"
4428 " recorded tinyint(4) NOT NULL DEFAULT '0',"
4429 " video tinyint(4) NOT NULL DEFAULT '0',"
4430 " dvd tinyint(4) NOT NULL DEFAULT '0',"
4431 " description varchar(32) NOT NULL,"
4432 " PRIMARY KEY (osdcategory)"
4433 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4434 "CREATE TABLE upnpmedia ("
4435 " intid int(10) unsigned NOT NULL DEFAULT '0',"
4436 " class varchar(64) NOT NULL DEFAULT '',"
4437 " itemtype varchar(128) NOT NULL DEFAULT '',"
4438 " parentid int(10) unsigned NOT NULL DEFAULT '0',"
4439 " itemproperties varchar(255) NOT NULL DEFAULT '',"
4440 " filepath varchar(512) NOT NULL DEFAULT '',"
4441 " title varchar(255) NOT NULL DEFAULT '',"
4442 " filename varchar(512) NOT NULL DEFAULT '',"
4443 " coverart varchar(512) NOT NULL DEFAULT '',"
4444 " PRIMARY KEY (intid),"
4445 " KEY class (class),"
4446 " KEY filepath (filepath(333)),"
4447 " KEY parentid (parentid)"
4448 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4449 "CREATE TABLE videocast ("
4450 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4451 " cast varchar(128) NOT NULL,"
4452 " PRIMARY KEY (intid)"
4453 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4454 "CREATE TABLE videocategory ("
4455 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4456 " category varchar(128) NOT NULL,"
4457 " PRIMARY KEY (intid)"
4458 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4459 "CREATE TABLE videocollection ("
4460 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4461 " title varchar(256) NOT NULL,"
4462 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
4463 " plot text,"
4464 " network varchar(128) DEFAULT NULL,"
4465 " collectionref varchar(128) NOT NULL,"
4466 " certification varchar(128) DEFAULT NULL,"
4467 " genre varchar(128) DEFAULT '',"
4468 " releasedate date DEFAULT NULL,"
4469 " `language` varchar(10) DEFAULT NULL,"
4470 " `status` varchar(64) DEFAULT NULL,"
4471 " rating float DEFAULT '0',"
4472 " ratingcount int(10) DEFAULT '0',"
4473 " runtime smallint(5) unsigned DEFAULT '0',"
4474 " banner text,"
4475 " fanart text,"
4476 " coverart text,"
4477 " PRIMARY KEY (intid),"
4478 " KEY title (title)"
4479 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4480 "CREATE TABLE videocountry ("
4481 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4482 " country varchar(128) NOT NULL,"
4483 " PRIMARY KEY (intid)"
4484 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4485 "CREATE TABLE videogenre ("
4486 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4487 " genre varchar(128) NOT NULL,"
4488 " PRIMARY KEY (intid)"
4489 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4490 "CREATE TABLE videometadata ("
4491 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4492 " title varchar(128) NOT NULL,"
4493 " subtitle text NOT NULL,"
4494 " tagline varchar(255) DEFAULT NULL,"
4495 " director varchar(128) NOT NULL,"
4496 " studio varchar(128) DEFAULT NULL,"
4497 " plot text,"
4498 " rating varchar(128) NOT NULL,"
4499 " inetref varchar(255) NOT NULL,"
4500 " collectionref int(10) NOT NULL DEFAULT '-1',"
4501 " homepage text NOT NULL,"
4502 " `year` int(10) unsigned NOT NULL,"
4503 " releasedate date NOT NULL,"
4504 " userrating float NOT NULL,"
4505 " length int(10) unsigned NOT NULL,"
4506 " playcount int(10) NOT NULL DEFAULT '0',"
4507 " season smallint(5) unsigned NOT NULL DEFAULT '0',"
4508 " episode smallint(5) unsigned NOT NULL DEFAULT '0',"
4509 " showlevel int(10) unsigned NOT NULL,"
4510 " filename text NOT NULL,"
4511 " `hash` varchar(128) NOT NULL,"
4512 " coverfile text NOT NULL,"
4513 " childid int(11) NOT NULL DEFAULT '-1',"
4514 " browse tinyint(1) NOT NULL DEFAULT '1',"
4515 " watched tinyint(1) NOT NULL DEFAULT '0',"
4516 " processed tinyint(1) NOT NULL DEFAULT '0',"
4517 " playcommand varchar(255) DEFAULT NULL,"
4518 " category int(10) unsigned NOT NULL DEFAULT '0',"
4519 " trailer text,"
4520 " `host` text NOT NULL,"
4521 " screenshot text,"
4522 " banner text,"
4523 " fanart text,"
4524 " insertdate timestamp NULL DEFAULT CURRENT_TIMESTAMP,"
4525 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
4526 " PRIMARY KEY (intid),"
4527 " KEY director (director),"
4528 " KEY title (title)"
4529 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4530 "CREATE TABLE videometadatacast ("
4531 " idvideo int(10) unsigned NOT NULL,"
4532 " idcast int(10) unsigned NOT NULL,"
4533 " UNIQUE KEY idvideo (idvideo,idcast)"
4534 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4535 "CREATE TABLE videometadatacountry ("
4536 " idvideo int(10) unsigned NOT NULL,"
4537 " idcountry int(10) unsigned NOT NULL,"
4538 " UNIQUE KEY idvideo_2 (idvideo,idcountry),"
4539 " KEY idvideo (idvideo),"
4540 " KEY idcountry (idcountry)"
4541 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4542 "CREATE TABLE videometadatagenre ("
4543 " idvideo int(10) unsigned NOT NULL,"
4544 " idgenre int(10) unsigned NOT NULL,"
4545 " UNIQUE KEY idvideo_2 (idvideo,idgenre),"
4546 " KEY idvideo (idvideo),"
4547 " KEY idgenre (idgenre)"
4548 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4549 "CREATE TABLE videopart ("
4550 " fileid bigint(20) unsigned NOT NULL,"
4551 " videoid int(10) unsigned NOT NULL,"
4552 " `order` smallint(5) unsigned NOT NULL DEFAULT '1',"
4553 " PRIMARY KEY (videoid,`order`)"
4554 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4555 "CREATE TABLE videopathinfo ("
4556 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4557 " path text,"
4558 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
4559 " collectionref int(10) DEFAULT '0',"
4560 " recurse tinyint(1) DEFAULT '0',"
4561 " PRIMARY KEY (intid)"
4562 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4563 "CREATE TABLE videosource ("
4564 " sourceid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4565 " `name` varchar(128) NOT NULL DEFAULT '',"
4566 " xmltvgrabber varchar(128) DEFAULT NULL,"
4567 " userid varchar(128) NOT NULL DEFAULT '',"
4568 " freqtable varchar(16) NOT NULL DEFAULT 'default',"
4569 " lineupid varchar(64) DEFAULT NULL,"
4570 " `password` varchar(64) DEFAULT NULL,"
4571 " useeit smallint(6) NOT NULL DEFAULT '0',"
4572 " configpath varchar(4096) DEFAULT NULL,"
4573 " dvb_nit_id int(6) DEFAULT '-1',"
4574 " PRIMARY KEY (sourceid),"
4575 " UNIQUE KEY `name` (`name`)"
4576 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4577 "CREATE TABLE videotypes ("
4578 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4579 " extension varchar(128) NOT NULL,"
4580 " playcommand varchar(255) NOT NULL,"
4581 " f_ignore tinyint(1) DEFAULT NULL,"
4582 " use_default tinyint(1) DEFAULT NULL,"
4583 " PRIMARY KEY (intid)"
4584 ") ENGINE=MyISAM AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;",
4585 
4586 "INSERT INTO channelgroupnames VALUES (1,'Favorites');",
4587 "INSERT INTO customexample VALUES ('New Flix','','program.category_type = \\'movie\\' AND program.airdate >= \\n YEAR(DATE_SUB(NOW(), INTERVAL 1 YEAR)) \\nAND program.stars > 0.5 ',1);",
4588 "INSERT INTO dtv_privatetypes VALUES ('dvb',9018,'channel_numbers','131');",
4589 "INSERT INTO dtv_privatetypes VALUES ('dvb',9018,'guide_fixup','2');",
4590 "INSERT INTO dtv_privatetypes VALUES ('dvb',256,'guide_fixup','1');",
4591 "INSERT INTO dtv_privatetypes VALUES ('dvb',257,'guide_fixup','1');",
4592 "INSERT INTO dtv_privatetypes VALUES ('dvb',256,'tv_types','1,150,134,133');",
4593 "INSERT INTO dtv_privatetypes VALUES ('dvb',257,'tv_types','1,150,134,133');",
4594 "INSERT INTO dtv_privatetypes VALUES ('dvb',4100,'sdt_mapping','1');",
4595 "INSERT INTO dtv_privatetypes VALUES ('dvb',4101,'sdt_mapping','1');",
4596 "INSERT INTO dtv_privatetypes VALUES ('dvb',4102,'sdt_mapping','1');",
4597 "INSERT INTO dtv_privatetypes VALUES ('dvb',4103,'sdt_mapping','1');",
4598 "INSERT INTO dtv_privatetypes VALUES ('dvb',4104,'sdt_mapping','1');",
4599 "INSERT INTO dtv_privatetypes VALUES ('dvb',4105,'sdt_mapping','1');",
4600 "INSERT INTO dtv_privatetypes VALUES ('dvb',4106,'sdt_mapping','1');",
4601 "INSERT INTO dtv_privatetypes VALUES ('dvb',4107,'sdt_mapping','1');",
4602 "INSERT INTO dtv_privatetypes VALUES ('dvb',4097,'sdt_mapping','1');",
4603 "INSERT INTO dtv_privatetypes VALUES ('dvb',4098,'sdt_mapping','1');",
4604 "INSERT INTO dtv_privatetypes VALUES ('dvb',4100,'tv_types','1,145,154');",
4605 "INSERT INTO dtv_privatetypes VALUES ('dvb',4101,'tv_types','1,145,154');",
4606 "INSERT INTO dtv_privatetypes VALUES ('dvb',4102,'tv_types','1,145,154');",
4607 "INSERT INTO dtv_privatetypes VALUES ('dvb',4103,'tv_types','1,145,154');",
4608 "INSERT INTO dtv_privatetypes VALUES ('dvb',4104,'tv_types','1,145,154');",
4609 "INSERT INTO dtv_privatetypes VALUES ('dvb',4105,'tv_types','1,145,154');",
4610 "INSERT INTO dtv_privatetypes VALUES ('dvb',4106,'tv_types','1,145,154');",
4611 "INSERT INTO dtv_privatetypes VALUES ('dvb',4107,'tv_types','1,145,154');",
4612 "INSERT INTO dtv_privatetypes VALUES ('dvb',4097,'tv_types','1,145,154');",
4613 "INSERT INTO dtv_privatetypes VALUES ('dvb',4098,'tv_types','1,145,154');",
4614 "INSERT INTO dtv_privatetypes VALUES ('dvb',4100,'guide_fixup','1');",
4615 "INSERT INTO dtv_privatetypes VALUES ('dvb',4101,'guide_fixup','1');",
4616 "INSERT INTO dtv_privatetypes VALUES ('dvb',4102,'guide_fixup','1');",
4617 "INSERT INTO dtv_privatetypes VALUES ('dvb',4103,'guide_fixup','1');",
4618 "INSERT INTO dtv_privatetypes VALUES ('dvb',4104,'guide_fixup','1');",
4619 "INSERT INTO dtv_privatetypes VALUES ('dvb',4105,'guide_fixup','1');",
4620 "INSERT INTO dtv_privatetypes VALUES ('dvb',4106,'guide_fixup','1');",
4621 "INSERT INTO dtv_privatetypes VALUES ('dvb',4107,'guide_fixup','1');",
4622 "INSERT INTO dtv_privatetypes VALUES ('dvb',4096,'guide_fixup','5');",
4623 "INSERT INTO dtv_privatetypes VALUES ('dvb',4097,'guide_fixup','1');",
4624 "INSERT INTO dtv_privatetypes VALUES ('dvb',4098,'guide_fixup','1');",
4625 "INSERT INTO dtv_privatetypes VALUES ('dvb',94,'tv_types','1,128');",
4626 "INSERT INTO dtv_privatetypes VALUES ('atsc',1793,'guide_fixup','3');",
4627 "INSERT INTO dtv_privatetypes VALUES ('dvb',40999,'guide_fixup','4');",
4628 "INSERT INTO dtv_privatetypes VALUES ('dvb',70,'force_guide_present','yes');",
4629 "INSERT INTO dtv_privatetypes VALUES ('dvb',70,'guide_ranges','80,80,96,96');",
4630 "INSERT INTO dtv_privatetypes VALUES ('dvb',4112,'channel_numbers','131');",
4631 "INSERT INTO dtv_privatetypes VALUES ('dvb',4115,'channel_numbers','131');",
4632 "INSERT INTO dtv_privatetypes VALUES ('dvb',4116,'channel_numbers','131');",
4633 "INSERT INTO dtv_privatetypes VALUES ('dvb',12802,'channel_numbers','131');",
4634 "INSERT INTO dtv_privatetypes VALUES ('dvb',12803,'channel_numbers','131');",
4635 "INSERT INTO dtv_privatetypes VALUES ('dvb',12829,'channel_numbers','131');",
4636 "INSERT INTO dtv_privatetypes VALUES ('dvb',40999,'parse_subtitle_list','1070,1308,1041,1306,1307,1030,1016,1131,1068,1069');",
4637 "INSERT INTO dtv_privatetypes VALUES ('dvb',4096,'guide_fixup','5');",
4638 "INSERT INTO dvdinput VALUES (1,720,480,16,9,1,1,'ntsc');",
4639 "INSERT INTO dvdinput VALUES (2,720,480,16,9,1,0,'ntsc');",
4640 "INSERT INTO dvdinput VALUES (3,720,480,4,3,1,1,'ntsc');",
4641 "INSERT INTO dvdinput VALUES (4,720,480,4,3,1,0,'ntsc');",
4642 "INSERT INTO dvdinput VALUES (5,720,576,16,9,3,1,'pal');",
4643 "INSERT INTO dvdinput VALUES (6,720,576,16,9,3,0,'pal');",
4644 "INSERT INTO dvdinput VALUES (7,720,576,4,3,3,1,'pal');",
4645 "INSERT INTO dvdinput VALUES (8,720,576,4,3,3,0,'pal');",
4646 "INSERT INTO dvdtranscode VALUES (1,1,'Good',2,1,16,16,0,0,2,0,0,0,0,0,32,32,8,8,'divx5',NULL,1618,NULL,NULL,0,NULL);",
4647 "INSERT INTO dvdtranscode VALUES (2,2,'Excellent',2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'divx5',NULL,0,NULL,NULL,1,NULL);",
4648 "INSERT INTO dvdtranscode VALUES (3,2,'Good',2,1,0,0,8,8,0,0,0,0,0,0,0,0,0,0,'divx5',NULL,1618,NULL,NULL,0,NULL);",
4649 "INSERT INTO dvdtranscode VALUES (4,2,'Medium',2,1,0,0,8,8,5,5,0,0,0,0,0,0,0,0,'divx5',NULL,1200,NULL,NULL,0,NULL);",
4650 "INSERT INTO dvdtranscode VALUES (5,3,'Good',2,1,0,0,0,0,0,0,0,0,2,0,80,80,8,8,'divx5',NULL,0,NULL,NULL,0,NULL);",
4651 "INSERT INTO dvdtranscode VALUES (6,4,'Excellent',2,1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,'divx5',NULL,0,NULL,NULL,1,NULL);",
4652 "INSERT INTO dvdtranscode VALUES (7,4,'Good',2,1,0,0,8,8,0,2,0,0,0,0,0,0,0,0,'divx5',NULL,1618,NULL,NULL,0,NULL);",
4653 "INSERT INTO dvdtranscode VALUES (8,5,'Good',1,1,16,16,0,0,5,0,0,0,0,0,40,40,8,8,'divx5',NULL,1618,NULL,NULL,0,NULL);",
4654 "INSERT INTO dvdtranscode VALUES (9,6,'Good',1,1,0,0,16,16,5,0,0,0,0,0,0,0,0,0,'divx5',NULL,1618,NULL,NULL,0,NULL);",
4655 "INSERT INTO dvdtranscode VALUES (10,7,'Good',1,1,0,0,0,0,1,0,0,0,0,0,76,76,8,8,'divx5',NULL,1618,NULL,NULL,0,NULL);",
4656 "INSERT INTO dvdtranscode VALUES (11,8,'Good',1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,'divx5',NULL,1618,NULL,NULL,0,NULL);",
4657 "INSERT INTO playgroup VALUES ('Default','',30,5,100,0);",
4658 "INSERT INTO profilegroups VALUES (1,'Software Encoders (v4l based)','V4L',1,NULL);",
4659 "INSERT INTO profilegroups VALUES (2,'IVTV MPEG-2 Encoders','MPEG',1,NULL);",
4660 "INSERT INTO profilegroups VALUES (3,'Hardware MJPEG Encoders (Matrox G200-TV, Miro DC10, etc)','MJPEG',1,NULL);",
4661 "INSERT INTO profilegroups VALUES (4,'Hardware HDTV','HDTV',1,NULL);",
4662 "INSERT INTO profilegroups VALUES (5,'Hardware DVB Encoders','DVB',1,NULL);",
4663 "INSERT INTO profilegroups VALUES (6,'Transcoders','TRANSCODE',1,NULL);",
4664 "INSERT INTO profilegroups VALUES (7,'FireWire Input','FIREWIRE',1,NULL);",
4665 "INSERT INTO profilegroups VALUES (8,'USB Mpeg-4 Encoder (Plextor ConvertX, etc)','GO7007',1,NULL);",
4666 "INSERT INTO profilegroups VALUES (14,'Import Recorder','IMPORT',1,NULL);",
4667 "INSERT INTO profilegroups VALUES (10,'Freebox Input','Freebox',1,NULL);",
4668 "INSERT INTO profilegroups VALUES (11,'HDHomeRun Recorders','HDHOMERUN',1,NULL);",
4669 "INSERT INTO profilegroups VALUES (12,'CRC IP Recorders','CRC_IP',1,NULL);",
4670 "INSERT INTO profilegroups VALUES (13,'HD-PVR Recorders','HDPVR',1,NULL);",
4671 "INSERT INTO profilegroups VALUES (15,'ASI Recorder (DVEO)','ASI',1,NULL);",
4672 "INSERT INTO profilegroups VALUES (16,'OCUR Recorder (CableLabs)','OCUR',1,NULL);",
4673 "INSERT INTO profilegroups VALUES (17,'Ceton Recorder','CETON',1,NULL);",
4674 "INSERT INTO record VALUES (1,11,0,'21:57:44','2012-08-11','21:57:44','2012-08-11','Default (Template)','','',0,0,'Default','Default',0,0,0,0,0,0,'Default',6,15,'','','','',0,0,1,0,0,0,0,1,-1,'00:00:00',735091,0,0,0,'Default',0,'0000-00-00 00:00:00','0000-00-00 00:00:00','0000-00-00 00:00:00','Default',100,0);",
4675 "INSERT INTO recordfilter VALUES (0,'New episode','program.previouslyshown = 0',0);",
4676 "INSERT INTO recordfilter VALUES (1,'Identifiable episode','program.generic = 0',0);",
4677 "INSERT INTO recordfilter VALUES (2,'First showing','program.first > 0',0);",
4678 "INSERT INTO recordfilter VALUES (3,'Prime time','HOUR(CONVERT_TZ(program.starttime, \\'Etc/UTC\\', \\'SYSTEM\\')) >= 19 AND HOUR(CONVERT_TZ(program.starttime, \\'Etc/UTC\\', \\'SYSTEM\\')) < 22',0);",
4679 "INSERT INTO recordfilter VALUES (4,'Commercial free','channel.commmethod = -2',0);",
4680 "INSERT INTO recordfilter VALUES (5,'High definition','program.hdtv > 0',0);",
4681 "INSERT INTO recordfilter VALUES (6,'This episode','(RECTABLE.programid <> \\'\\' AND program.programid = RECTABLE.programid) OR (RECTABLE.programid = \\'\\' AND program.subtitle = RECTABLE.subtitle AND program.description = RECTABLE.description)',0);",
4682 "INSERT INTO recordfilter VALUES (7,'This series','(RECTABLE.seriesid <> \\'\\' AND program.seriesid = RECTABLE.seriesid)',0);",
4683 "INSERT INTO recordingprofiles VALUES (1,'Default',NULL,NULL,1);",
4684 "INSERT INTO recordingprofiles VALUES (2,'Live TV',NULL,NULL,1);",
4685 "INSERT INTO recordingprofiles VALUES (3,'High Quality',NULL,NULL,1);",
4686 "INSERT INTO recordingprofiles VALUES (4,'Low Quality',NULL,NULL,1);",
4687 "INSERT INTO recordingprofiles VALUES (5,'Default',NULL,NULL,2);",
4688 "INSERT INTO recordingprofiles VALUES (6,'Live TV',NULL,NULL,2);",
4689 "INSERT INTO recordingprofiles VALUES (7,'High Quality',NULL,NULL,2);",
4690 "INSERT INTO recordingprofiles VALUES (8,'Low Quality',NULL,NULL,2);",
4691 "INSERT INTO recordingprofiles VALUES (9,'Default',NULL,NULL,3);",
4692 "INSERT INTO recordingprofiles VALUES (10,'Live TV',NULL,NULL,3);",
4693 "INSERT INTO recordingprofiles VALUES (11,'High Quality',NULL,NULL,3);",
4694 "INSERT INTO recordingprofiles VALUES (12,'Low Quality',NULL,NULL,3);",
4695 "INSERT INTO recordingprofiles VALUES (13,'Default',NULL,NULL,4);",
4696 "INSERT INTO recordingprofiles VALUES (14,'Live TV',NULL,NULL,4);",
4697 "INSERT INTO recordingprofiles VALUES (15,'High Quality',NULL,NULL,4);",
4698 "INSERT INTO recordingprofiles VALUES (16,'Low Quality',NULL,NULL,4);",
4699 "INSERT INTO recordingprofiles VALUES (17,'Default',NULL,NULL,5);",
4700 "INSERT INTO recordingprofiles VALUES (18,'Live TV',NULL,NULL,5);",
4701 "INSERT INTO recordingprofiles VALUES (19,'High Quality',NULL,NULL,5);",
4702 "INSERT INTO recordingprofiles VALUES (20,'Low Quality',NULL,NULL,5);",
4703 "INSERT INTO recordingprofiles VALUES (21,'RTjpeg/MPEG4',NULL,NULL,6);",
4704 "INSERT INTO recordingprofiles VALUES (22,'MPEG2',NULL,NULL,6);",
4705 "INSERT INTO recordingprofiles VALUES (23,'Default',NULL,NULL,8);",
4706 "INSERT INTO recordingprofiles VALUES (24,'Live TV',NULL,NULL,8);",
4707 "INSERT INTO recordingprofiles VALUES (25,'High Quality',NULL,NULL,8);",
4708 "INSERT INTO recordingprofiles VALUES (26,'Low Quality',NULL,NULL,8);",
4709 "INSERT INTO recordingprofiles VALUES (27,'High Quality',NULL,NULL,6);",
4710 "INSERT INTO recordingprofiles VALUES (28,'Medium Quality',NULL,NULL,6);",
4711 "INSERT INTO recordingprofiles VALUES (29,'Low Quality',NULL,NULL,6);",
4712 "INSERT INTO recordingprofiles VALUES (30,'Default',NULL,NULL,10);",
4713 "INSERT INTO recordingprofiles VALUES (31,'Live TV',NULL,NULL,10);",
4714 "INSERT INTO recordingprofiles VALUES (32,'High Quality',NULL,NULL,10);",
4715 "INSERT INTO recordingprofiles VALUES (33,'Low Quality',NULL,NULL,10);",
4716 "INSERT INTO recordingprofiles VALUES (34,'Default',NULL,NULL,11);",
4717 "INSERT INTO recordingprofiles VALUES (35,'Live TV',NULL,NULL,11);",
4718 "INSERT INTO recordingprofiles VALUES (36,'High Quality',NULL,NULL,11);",
4719 "INSERT INTO recordingprofiles VALUES (37,'Low Quality',NULL,NULL,11);",
4720 "INSERT INTO recordingprofiles VALUES (38,'Default',NULL,NULL,12);",
4721 "INSERT INTO recordingprofiles VALUES (39,'Live TV',NULL,NULL,12);",
4722 "INSERT INTO recordingprofiles VALUES (40,'High Quality',NULL,NULL,12);",
4723 "INSERT INTO recordingprofiles VALUES (41,'Low Quality',NULL,NULL,12);",
4724 "INSERT INTO recordingprofiles VALUES (42,'Default',NULL,NULL,7);",
4725 "INSERT INTO recordingprofiles VALUES (43,'Live TV',NULL,NULL,7);",
4726 "INSERT INTO recordingprofiles VALUES (44,'High Quality',NULL,NULL,7);",
4727 "INSERT INTO recordingprofiles VALUES (45,'Low Quality',NULL,NULL,7);",
4728 "INSERT INTO recordingprofiles VALUES (46,'Default',NULL,NULL,9);",
4729 "INSERT INTO recordingprofiles VALUES (47,'Live TV',NULL,NULL,9);",
4730 "INSERT INTO recordingprofiles VALUES (48,'High Quality',NULL,NULL,9);",
4731 "INSERT INTO recordingprofiles VALUES (49,'Low Quality',NULL,NULL,9);",
4732 "INSERT INTO recordingprofiles VALUES (50,'Default',NULL,NULL,13);",
4733 "INSERT INTO recordingprofiles VALUES (51,'Live TV',NULL,NULL,13);",
4734 "INSERT INTO recordingprofiles VALUES (52,'High Quality',NULL,NULL,13);",
4735 "INSERT INTO recordingprofiles VALUES (53,'Low Quality',NULL,NULL,13);",
4736 "INSERT INTO recordingprofiles VALUES (54,'Default',NULL,NULL,14);",
4737 "INSERT INTO recordingprofiles VALUES (55,'Live TV',NULL,NULL,14);",
4738 "INSERT INTO recordingprofiles VALUES (56,'High Quality',NULL,NULL,14);",
4739 "INSERT INTO recordingprofiles VALUES (57,'Low Quality',NULL,NULL,14);",
4740 "INSERT INTO recordingprofiles VALUES (58,'Default',NULL,NULL,15);",
4741 "INSERT INTO recordingprofiles VALUES (59,'Live TV',NULL,NULL,15);",
4742 "INSERT INTO recordingprofiles VALUES (60,'High Quality',NULL,NULL,15);",
4743 "INSERT INTO recordingprofiles VALUES (61,'Low Quality',NULL,NULL,15);",
4744 "INSERT INTO recordingprofiles VALUES (62,'Default',NULL,NULL,16);",
4745 "INSERT INTO recordingprofiles VALUES (63,'Live TV',NULL,NULL,16);",
4746 "INSERT INTO recordingprofiles VALUES (64,'High Quality',NULL,NULL,16);",
4747 "INSERT INTO recordingprofiles VALUES (65,'Low Quality',NULL,NULL,16);",
4748 "INSERT INTO recordingprofiles VALUES (66,'Default',NULL,NULL,17);",
4749 "INSERT INTO recordingprofiles VALUES (67,'Live TV',NULL,NULL,17);",
4750 "INSERT INTO recordingprofiles VALUES (68,'High Quality',NULL,NULL,17);",
4751 "INSERT INTO recordingprofiles VALUES (69,'Low Quality',NULL,NULL,17);",
4752 "INSERT INTO settings VALUES ('mythfilldatabaseLastRunStart','',NULL);",
4753 "INSERT INTO settings VALUES ('mythfilldatabaseLastRunEnd','',NULL);",
4754 "INSERT INTO settings VALUES ('mythfilldatabaseLastRunStatus','',NULL);",
4755 "INSERT INTO settings VALUES ('DataDirectMessage','',NULL);",
4756 "INSERT INTO settings VALUES ('HaveRepeats','0',NULL);",
4757 "INSERT INTO settings VALUES ('DBSchemaVer','1307',NULL);",
4758 "INSERT INTO settings VALUES ('DefaultTranscoder','0',NULL);",
4759 "INSERT INTO videotypes VALUES (1,'txt','',1,0);",
4760 "INSERT INTO videotypes VALUES (2,'log','',1,0);",
4761 "INSERT INTO videotypes VALUES (3,'mpg','Internal',0,0);",
4762 "INSERT INTO videotypes VALUES (4,'avi','',0,1);",
4763 "INSERT INTO videotypes VALUES (5,'vob','Internal',0,0);",
4764 "INSERT INTO videotypes VALUES (6,'mpeg','Internal',0,0);",
4765 "INSERT INTO videotypes VALUES (8,'iso','Internal',0,0);",
4766 "INSERT INTO videotypes VALUES (9,'img','Internal',0,0);",
4767 "INSERT INTO videotypes VALUES (10,'mkv','Internal',0,0);",
4768 "INSERT INTO videotypes VALUES (11,'mp4','Internal',0,0);",
4769 "INSERT INTO videotypes VALUES (12,'m2ts','Internal',0,0);",
4770 "INSERT INTO videotypes VALUES (13,'evo','Internal',0,0);",
4771 "INSERT INTO videotypes VALUES (14,'divx','Internal',0,0);",
4772 "INSERT INTO videotypes VALUES (15,'mov','Internal',0,0);",
4773 "INSERT INTO videotypes VALUES (16,'qt','Internal',0,0);",
4774 "INSERT INTO videotypes VALUES (17,'wmv','Internal',0,0);",
4775 "INSERT INTO videotypes VALUES (18,'3gp','Internal',0,0);",
4776 "INSERT INTO videotypes VALUES (19,'asf','Internal',0,0);",
4777 "INSERT INTO videotypes VALUES (20,'ogg','Internal',0,0);",
4778 "INSERT INTO videotypes VALUES (21,'ogm','Internal',0,0);",
4779 "INSERT INTO videotypes VALUES (22,'flv','Internal',0,0);",
4780 "INSERT INTO videotypes VALUES (23,'ogv','Internal',0,0);",
4781 "INSERT INTO videotypes VALUES (25,'nut','Internal',0,0);",
4782 "INSERT INTO videotypes VALUES (26,'mxf','Internal',0,0);",
4783 "INSERT INTO videotypes VALUES (27,'m4v','Internal',0,0);",
4784 "INSERT INTO videotypes VALUES (28,'rm','Internal',0,0);",
4785 "INSERT INTO videotypes VALUES (29,'ts','Internal',0,0);",
4786 "INSERT INTO videotypes VALUES (30,'swf','Internal',0,0);",
4787 "INSERT INTO videotypes VALUES (31,'f4v','Internal',0,0);",
4788 "INSERT INTO videotypes VALUES (32,'nuv','Internal',0,0);",
4789 nullptr
4790 };
4791 
4792  QString dbver = "";
4793  if (!performActualUpdate(updates, "1307", dbver))
4794  return false;
4795 
4796  GetMythDB()->SetHaveSchema(true);
4797 
4798  return true;
4799 }
4800 
4801 /* vim: set expandtab tabstop=4 shiftwidth=4: */
QString m_fileName
Definition: recordingfile.h:44
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:794
Provides UI and helper functions for DB Schema updates.
Definition: schemawizard.h:25
void bindValue(const QString &placeholder, const QVariant &val)
Definition: mythdbcon.cpp:875
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
QString dbName
database name
Definition: mythdbparams.h:26
static uint CreateInputGroup(const QString &name)
Definition: cardutil.cpp:1355
static bool performActualUpdate(const char **updates, const char *version, QString &dbver)
Runs a number of SQL commands, and updates the schema version.
QSize m_videoResolution
Definition: recordingfile.h:50
static bool UpdateDBVersionNumber(const QString &newnumber, QString &dbver)
Updates the schema version stored in the database.
QString m_storageGroup
Definition: recordingfile.h:41
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
static bool performUpdateSeries(const char **updates)
Runs a number of SQL commands.
int size(void) const
Definition: mythdbcon.h:187
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:34
MarkTypes QueryAverageAspectRatio(void) const
unsigned int uint
Definition: compat.h:140
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
RecordingType m_type
RecordingDupMethodType m_dupMethod
RecordingFile * GetRecordingFile() const
bool doUpgradeVideoDatabaseSchema(void)
static bool doUpgradeTVDatabaseSchema(void)
This is called by UpgradeTVDatabaseSchema() to actually upgrade the schema to what MythTV expects.
QString GetStorageGroup(void) const
Definition: programinfo.h:416
QVariant value(int i) const
Definition: mythdbcon.h:182
bool Save(bool sendSig=true)
uint QueryAverageHeight(void) const
If present in recording this loads average height of the main video stream from database's stream mar...
static SchemaUpgradeWizard * Get(const QString &DBSchemaSetting, const QString &appName, const QString &upgradeSchemaVal)
Instead of creating a new wizard, use the existing one for its DB backup file & results and expert se...
enum MythSchemaUpgrade PromptForUpgrade(const char *name, const bool upgradeAllowed, const bool upgradeIfNoUI, const int minDMBSmajor=0, const int minDBMSminor=0, const int minDBMSpoint=0)
Query user, to prevent silent, automatic database upgrades.
QSqlError lastError(void) const
Definition: mythdbcon.h:186
QVariant lastInsertId()
Return the id of the last inserted row.
Definition: mythdbcon.cpp:889
QString m_storageDeviceID
Definition: recordingfile.h:40
uint QueryAverageWidth(void) const
If present in recording this loads average width of the main video stream from database's stream mark...
QString GetBasename(void) const
Definition: programinfo.h:338
bool m_autoMetadataLookup
QString GetSetting(const QString &key, const QString &defaultval="")
int Compare(void)
How many schema versions old is the DB?
static const uint TranscoderAutodetect
sentinel value
bool isActive(void) const
Definition: mythdbcon.h:188
double m_videoFrameRate
Definition: recordingfile.h:52
string hostname
Definition: caa.py:17
static bool UnlinkInputGroup(uint inputid, uint inputgroupid)
Definition: cardutil.cpp:1474
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:547
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:31
double m_videoAspectRatio
Definition: recordingfile.h:51
Holds information on a recording file and it's video and audio streams.
Definition: recordingfile.h:29
const char * name
Definition: ParseText.cpp:339
static unsigned GetDefaultFilter(void)
bool IsMasterHost(void)
is this the same host as the master
uint QueryAverageFrameRate(void) const
If present in recording this loads average frame rate of the main video stream from database's stream...
bool MakeTemplate(QString category)
uint64_t GetFilesize(void) const override
int GetNumSetting(const QString &key, int defaultval=0)
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:819
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
bool GetBoolSetting(const QString &key, bool defaultval=false)
DatabaseParams GetDatabaseParams(void)
const QString currentDatabaseVersion
static void UnlockSchema(MSqlQuery &)
Definition: dbutil.cpp:867
unsigned m_filter
static QString DBErrorMessage(const QSqlError &err)
Definition: mythdb.cpp:184
QString GetHostname(void) const
Definition: programinfo.h:415
static bool TryLockSchema(MSqlQuery &, uint timeout_secs)
Try to get a lock on the table schemalock.
Definition: dbutil.cpp:860
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:615
MythDB * GetMythDB(void)
Definition: mythdb.cpp:46
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
static bool LinkInputGroup(uint inputid, uint inputgroupid)
Definition: cardutil.cpp:1434
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
void ActivateSettingsCache(bool activate=true)
deprecated, it is only 1:1 sample aspect ratio
Definition: programtypes.h:65
#define db_sd_notify(x)
QString GetHostName(void)
#define MINIMUM_DBMS_VERSION
static bool IsNewDatabase(void)
Returns true for a new (empty) database.
Definition: dbutil.cpp:83
bool InitializeMythSchema(void)
command to get the the initial database layout from an empty database:
#define MYTH_DATABASE_VERSION
Increment this whenever the MythTV core database schema changes.
Definition: mythversion.h:78
uint64_t m_fileSize
Definition: recordingfile.h:45