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