MythTV  master
dbcheck.cpp
Go to the documentation of this file.
1 #include <cstdio>
2 #include <iostream>
3 
4 #include <QString>
5 #include <QSqlError>
6 
7 #include "libmyth/schemawizard.h"
8 #include "libmythbase/compat.h"
9 #include "libmythbase/dbutil.h"
10 #include "libmythbase/mythconfig.h"
12 #include "libmythbase/mythdb.h"
15 #include "libmythbase/mythversion.h"
16 
17 #include "cardutil.h"
18 #include "dbcheck.h"
19 #include "mythvideoprofile.h"
20 #include "recordinginfo.h"
21 #include "recordingprofile.h"
22 #include "recordingrule.h"
23 #include "videodbcheck.h" // for 1267
24 
25 // TODO convert all dates to UTC
26 
27 #define MINIMUM_DBMS_VERSION 5,0,15
28 
29 const QString currentDatabaseVersion = MYTH_DATABASE_VERSION;
30 
31 static bool doUpgradeTVDatabaseSchema(void);
32 
33 #if CONFIG_SYSTEMD_NOTIFY
34 #include <systemd/sd-daemon.h>
35 static inline void db_sd_notify(const char *str)
36 {
37  sd_notifyf(0, "STATUS=Database update: %s", str);
38 }
39 #else
40 static inline void db_sd_notify(const char */*str*/) {};
41 #endif
42 
361 bool UpgradeTVDatabaseSchema(const bool upgradeAllowed,
362  const bool upgradeIfNoUI,
363  [[maybe_unused]] const bool informSystemd)
364 {
365 #ifdef IGNORE_SCHEMA_VER_MISMATCH
366  return true;
367 #endif
368  SchemaUpgradeWizard *schema_wizard = nullptr;
369 
370  // Suppress DB messages and turn of the settings cache,
371  // These are likely to confuse the users and the code, respectively.
372  GetMythDB()->SetSuppressDBMessages(true);
374 
375  // Get the schema upgrade lock
376  MSqlQuery query(MSqlQuery::InitCon());
377  bool locked = DBUtil::TryLockSchema(query, 1);
378  for (uint i = 0; i < 2*60 && !locked; i++)
379  {
380  if (informSystemd)
381  db_sd_notify("waiting for lock");
382  LOG(VB_GENERAL, LOG_INFO, "Waiting for database schema upgrade lock");
383  locked = DBUtil::TryLockSchema(query, 1);
384  if (locked)
385  LOG(VB_GENERAL, LOG_INFO, "Got schema upgrade lock");
386  }
387  if (!locked)
388  {
389  LOG(VB_GENERAL, LOG_INFO, "Failed to get schema upgrade lock");
390  goto upgrade_error_exit;
391  }
392 
393  // Determine if an upgrade is needed
394  schema_wizard = SchemaUpgradeWizard::Get(
395  "DBSchemaVer", "MythTV", currentDatabaseVersion);
396  if (schema_wizard->Compare() == 0) // DB schema is what we need it to be..
397  goto upgrade_ok_exit;
398 
399  if (!upgradeAllowed)
400  LOG(VB_GENERAL, LOG_WARNING, "Not allowed to upgrade the database.");
401 
402  if (informSystemd)
403  db_sd_notify("waiting for user input");
404  // Pop up messages, questions, warnings, etc.
405  switch (schema_wizard->PromptForUpgrade(
406  "TV", upgradeAllowed, upgradeIfNoUI, MINIMUM_DBMS_VERSION))
407  {
409  goto upgrade_ok_exit;
410  case MYTH_SCHEMA_ERROR:
411  case MYTH_SCHEMA_EXIT:
412  goto upgrade_error_exit;
413  case MYTH_SCHEMA_UPGRADE:
414  break;
415  }
416 
417  LOG(VB_GENERAL, LOG_DEBUG, QString("Newest MythTV Schema Version : %1")
418  .arg(currentDatabaseVersion));
419 
420  // Upgrade the schema
421  if (informSystemd)
422  db_sd_notify("upgrading database");
424  {
425  LOG(VB_GENERAL, LOG_ERR, "Database schema upgrade failed.");
426  goto upgrade_error_exit;
427  }
428 
429  LOG(VB_GENERAL, LOG_INFO, "Database schema upgrade complete.");
430 
431  // On any exit we want to re-enable the DB messages so errors
432  // are reported and we want to make sure the setting cache is
433  // enabled for good performance and we must unlock the schema
434  // lock. We use gotos with labels so it's impossible to miss
435  // these steps.
436  upgrade_ok_exit:
437  if (informSystemd)
438  db_sd_notify("success");
439  GetMythDB()->SetSuppressDBMessages(false);
441  if (locked)
442  DBUtil::UnlockSchema(query);
443  return true;
444 
445  upgrade_error_exit:
446  if (informSystemd)
447  db_sd_notify("failed");
448  GetMythDB()->SetSuppressDBMessages(false);
450  if (locked)
451  DBUtil::UnlockSchema(query);
452  return false;
453 }
454 
468 static bool doUpgradeTVDatabaseSchema(void)
469 {
470  QString order;
471 
472  auto ss2ba = [](const auto & ss){ return QByteArray::fromStdString(ss); };
473  auto qs2ba = [](const auto & item){ return item.constData(); };
474  auto add_start_end = [order](const auto & field){
475  return QString("UPDATE %1 "
476  "SET starttime = CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC'), "
477  " endtime = CONVERT_TZ(endtime, 'SYSTEM', 'Etc/UTC') "
478  "ORDER BY %2")
479  .arg(QString::fromStdString(field)).arg(order).toLocal8Bit(); };
480  auto add_start = [order](const auto & field){
481  return QString("UPDATE %1 "
482  "SET starttime = CONVERT_TZ(starttime, 'SYSTEM', 'Etc/UTC') "
483  "ORDER BY %2")
484  .arg(QString::fromStdString(field)).arg(order).toLocal8Bit(); };
485 
486  QString dbver = gCoreContext->GetSetting("DBSchemaVer");
487  if (dbver == currentDatabaseVersion)
488  {
489  return true;
490  }
491 
492  // Don't rely on this, please specify these when creating the database.
493  {
494  MSqlQuery query(MSqlQuery::InitCon());
495  if (!query.exec(QString("ALTER DATABASE %1 DEFAULT "
496  "CHARACTER SET utf8 COLLATE utf8_general_ci;")
497  .arg(GetMythDB()->GetDatabaseName())))
498  {
499  MythDB::DBError("UpgradeTVDatabaseSchema -- alter charset", query);
500  }
501  }
502 
503  if (DBUtil::IsNewDatabase())
504  {
505  if (!InitializeMythSchema())
506  return false;
507  dbver = gCoreContext->GetSetting("DBSchemaVer");
508  }
509 
510  if (dbver.isEmpty() || dbver.toInt() < 1027)
511  {
512  LOG(VB_GENERAL, LOG_ERR, "Unrecognized database schema version. "
513  "Unable to upgrade database.");
514  return false;
515  }
516  if (dbver.toInt() < 1244)
517  {
518  LOG(VB_GENERAL, LOG_ERR, "Your database version is too old to upgrade "
519  "with this version of MythTV. You will need "
520  "to use mythtv-setup from MythTV 0.22, 0.23, "
521  "or 0.24 to upgrade your database before "
522  "upgrading to this version of MythTV.");
523  return false;
524  }
525 
526  if (dbver == "1244")
527  {
528  DBUpdates updates {
529 "ALTER TABLE cardinput DROP COLUMN freetoaironly;",
530 "ALTER TABLE cardinput DROP COLUMN radioservices;"
531 };
532  if (!performActualUpdate("MythTV", "DBSchemaVer",
533  updates, "1245", dbver))
534  return false;
535  }
536 
537  if (dbver == "1245")
538  {
539  DBUpdates updates {
540 "DELETE FROM capturecard WHERE cardtype = 'DBOX2';",
541 "DELETE FROM profilegroups WHERE cardtype = 'DBOX2';",
542 "ALTER TABLE capturecard DROP COLUMN dbox2_port;",
543 "ALTER TABLE capturecard DROP COLUMN dbox2_httpport;",
544 "ALTER TABLE capturecard DROP COLUMN dbox2_host;"
545 };
546  if (!performActualUpdate("MythTV", "DBSchemaVer",
547  updates, "1246", dbver))
548  return false;
549  }
550 
551  if (dbver == "1246")
552  {
553  DBUpdates updates {
554 "ALTER TABLE recorded ADD COLUMN bookmarkupdate timestamp default 0 NOT NULL",
555 "UPDATE recorded SET bookmarkupdate = lastmodified+1 WHERE bookmark = 1",
556 "UPDATE recorded SET bookmarkupdate = lastmodified WHERE bookmark = 0"
557 };
558  if (!performActualUpdate("MythTV", "DBSchemaVer",
559  updates, "1247", dbver))
560  return false;
561  }
562 
563  if (dbver == "1247")
564  {
565  DBUpdates updates {
566 "INSERT INTO profilegroups SET name = \"Import Recorder\", cardtype = 'IMPORT', is_default = 1;",
567 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 14;",
568 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 14;",
569 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 14;",
570 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 14;"
571 };
572  if (!performActualUpdate("MythTV", "DBSchemaVer",
573  updates, "1248", dbver))
574  return false;
575  }
576 
577  if (dbver == "1248")
578  {
579  DBUpdates updates {
580 "DELETE FROM keybindings WHERE action = 'CUSTOMEDIT' "
581  "AND context = 'TV Frontend' AND keylist = 'E';"
582 };
583  if (!performActualUpdate("MythTV", "DBSchemaVer",
584  updates, "1249", dbver))
585  return false;
586  }
587 
588  if (dbver == "1249")
589  {
590  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1250");
591 
592  MSqlQuery select(MSqlQuery::InitCon());
593  select.prepare("SELECT hostname, data FROM settings "
594  " WHERE value = 'StickyKeys'");
595 
596  if (!select.exec())
597  {
598  MythDB::DBError("Unable to retrieve StickyKeys values.", select);
599  }
600  else
601  {
602  MSqlQuery update(MSqlQuery::InitCon());
603  while (select.next())
604  {
605  QString hostname = select.value(0).toString();
606  QString sticky_keys = select.value(1).toString();
607 
608  if ("1" == sticky_keys)
609  {
610  // Only remap the keys if they're currently set to defaults
611  update.prepare("UPDATE keybindings "
612  " SET keylist = :KEYS "
613  " WHERE context = 'TV Playback' AND "
614  " action = :ACTION AND "
615  " hostname = :HOSTNAME AND "
616  " keylist = :DEFAULT_KEYS");
617 
618  QString keylist = "";
619  QString action = "SEEKFFWD";
620  QString default_keys = "Right";
621 
622  update.bindValue(":KEYS", keylist);
623  update.bindValue(":ACTION", action);
624  update.bindValue(":HOSTNAME", hostname);
625  update.bindValue(":DEFAULT_KEYS", default_keys);
626  if (!update.exec())
627  MythDB::DBError("Unable to update keybindings",
628  update);
629 
630  keylist = "";
631  action = "SEEKRWND";
632  default_keys = "Left";
633 
634  update.bindValue(":KEYS", keylist);
635  update.bindValue(":ACTION", action);
636  update.bindValue(":HOSTNAME", hostname);
637  update.bindValue(":DEFAULT_KEYS", default_keys);
638  if (!update.exec())
639  MythDB::DBError("Unable to update keybindings",
640  update);
641 
642  keylist = ">,.,Right";
643  action = "FFWDSTICKY";
644  default_keys = ">,.";
645 
646  update.bindValue(":KEYS", keylist);
647  update.bindValue(":ACTION", action);
648  update.bindValue(":HOSTNAME", hostname);
649  update.bindValue(":DEFAULT_KEYS", default_keys);
650  if (!update.exec())
651  MythDB::DBError("Unable to update keybindings",
652  update);
653 
654  keylist = ",,<,Left";
655  action = "RWNDSTICKY";
656  default_keys = ",,<";
657 
658  update.bindValue(":KEYS", keylist);
659  update.bindValue(":ACTION", action);
660  update.bindValue(":HOSTNAME", hostname);
661  update.bindValue(":DEFAULT_KEYS", default_keys);
662  if (!update.exec())
663  MythDB::DBError("Unable to update keybindings",
664  update);
665  }
666  }
667  }
668 
669  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1250", dbver))
670  return false;
671  }
672 
673  if (dbver == "1250")
674  {
675  DBUpdates updates {
676 "UPDATE recorded SET bookmark = 1 WHERE bookmark != 0;"
677 };
678  if (!performActualUpdate("MythTV", "DBSchemaVer",
679  updates, "1251", dbver))
680  return false;
681  }
682 
683  if (dbver == "1251")
684  {
685  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1252");
686 
687  MSqlQuery query(MSqlQuery::InitCon());
688  query.prepare("SHOW INDEX FROM recgrouppassword");
689 
690  if (!query.exec())
691  {
692  MythDB::DBError("Unable to retrieve current indices on "
693  "recgrouppassword.", query);
694  }
695  else
696  {
697  while (query.next())
698  {
699  QString index_name = query.value(2).toString();
700 
701  if ("recgroup" == index_name)
702  {
703  MSqlQuery update(MSqlQuery::InitCon());
704  update.prepare("ALTER TABLE recgrouppassword "
705  " DROP INDEX recgroup");
706 
707  if (!update.exec())
708  {
709  MythDB::DBError("Unable to drop duplicate index on "
710  "recgrouppassword. Ignoring.",
711  update);
712  }
713  break;
714  }
715  }
716  }
717 
718  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1252", dbver))
719  return false;
720  }
721 
722  if (dbver == "1252")
723  {
724  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1253");
725 
726  MSqlQuery select(MSqlQuery::InitCon());
727  select.prepare("SELECT hostname, data FROM settings "
728  " WHERE value = 'StickyKeys'");
729 
730  if (!select.exec())
731  {
732  MythDB::DBError("Unable to retrieve StickyKeys values.", select);
733  }
734  else
735  {
736  MSqlQuery update(MSqlQuery::InitCon());
737  while (select.next())
738  {
739  QString hostname = select.value(0).toString();
740  QString sticky_keys = select.value(1).toString();
741 
742  if ("1" == sticky_keys)
743  {
744  // Only remap the keys if they're currently set to defaults
745  update.prepare("UPDATE keybindings "
746  " SET keylist = :KEYS "
747  " WHERE context = 'TV Playback' AND "
748  " action = :ACTION AND "
749  " hostname = :HOSTNAME AND "
750  " keylist = :DEFAULT_KEYS");
751 
752  QString keylist = ">,.";
753  QString action = "FFWDSTICKY";
754  QString default_keys = ">,.,Right";
755 
756  update.bindValue(":KEYS", keylist);
757  update.bindValue(":ACTION", action);
758  update.bindValue(":HOSTNAME", hostname);
759  update.bindValue(":DEFAULT_KEYS", default_keys);
760  if (!update.exec())
761  MythDB::DBError("Unable to update keybindings",
762  update);
763 
764  keylist = ",,<";
765  action = "RWNDSTICKY";
766  default_keys = ",,<,Left";
767 
768  update.bindValue(":KEYS", keylist);
769  update.bindValue(":ACTION", action);
770  update.bindValue(":HOSTNAME", hostname);
771  update.bindValue(":DEFAULT_KEYS", default_keys);
772  if (!update.exec())
773  MythDB::DBError("Unable to update keybindings",
774  update);
775  }
776  }
777  }
778 
779  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1253", dbver))
780  return false;
781  }
782 
783  if (dbver == "1253")
784  {
785  if (gCoreContext->GetNumSetting("have-nit-fix") == 1)
786  {
787  // User has previously applied patch from ticket #7486.
788  LOG(VB_GENERAL, LOG_CRIT,
789  "Upgrading to MythTV schema version 1254");
790  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1254", dbver))
791  return false;
792  }
793  else
794  {
795  DBUpdates updates {
796  "ALTER TABLE videosource ADD dvb_nit_id INT(6) DEFAULT -1;"
797  };
798  if (!performActualUpdate("MythTV", "DBSchemaVer",
799  updates, "1254", dbver))
800  return false;
801  }
802  }
803 
804  if (dbver == "1254")
805  {
806  DBUpdates updates {
807 "ALTER TABLE cardinput DROP COLUMN shareable;"
808 };
809  if (!performActualUpdate("MythTV", "DBSchemaVer",
810  updates, "1255", dbver))
811  return false;
812  }
813 
814  if (dbver == "1255")
815  {
816  DBUpdates updates {
817 "INSERT INTO keybindings (SELECT 'Main Menu', 'EXIT', 'System Exit', "
818  "(CASE data WHEN '1' THEN 'Ctrl+Esc' WHEN '2' THEN 'Meta+Esc' "
819  "WHEN '3' THEN 'Alt+Esc' WHEN '4' THEN 'Esc' ELSE '' END), hostname "
820  "FROM settings WHERE value = 'AllowQuitShutdown' GROUP BY hostname) "
821  "ON DUPLICATE KEY UPDATE keylist = VALUES(keylist);"
822 };
823  if (!performActualUpdate("MythTV", "DBSchemaVer",
824  updates, "1256", dbver))
825  return false;
826  }
827 
828  if (dbver == "1256")
829  {
830  DBUpdates updates {
831 "ALTER TABLE record DROP COLUMN tsdefault;"
832 };
833  if (!performActualUpdate("MythTV", "DBSchemaVer",
834  updates, "1257", dbver))
835  return false;
836  }
837 
838  if (dbver == "1257")
839  {
840  DBUpdates updates {
841 "CREATE TABLE internetcontent "
842 "( name VARCHAR(255) NOT NULL,"
843 " thumbnail VARCHAR(255),"
844 " type SMALLINT(3) NOT NULL,"
845 " author VARCHAR(128) NOT NULL,"
846 " description TEXT NOT NULL,"
847 " commandline TEXT NOT NULL,"
848 " version DOUBLE NOT NULL,"
849 " updated DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"
850 " search BOOL NOT NULL,"
851 " tree BOOL NOT NULL,"
852 " podcast BOOL NOT NULL,"
853 " download BOOL NOT NULL,"
854 " host VARCHAR(128)) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
855 "CREATE TABLE internetcontentarticles "
856 "( feedtitle VARCHAR(255) NOT NULL,"
857 " path TEXT NOT NULL,"
858 " paththumb TEXT NOT NULL,"
859 " title VARCHAR(255) NOT NULL,"
860 " subtitle VARCHAR(255) NOT NULL,"
861 " season SMALLINT(5) NOT NULL DEFAULT '0',"
862 " episode SMALLINT(5) NOT NULL DEFAULT '0',"
863 " description TEXT NOT NULL,"
864 " url TEXT NOT NULL,"
865 " type SMALLINT(3) NOT NULL,"
866 " thumbnail TEXT NOT NULL,"
867 " mediaURL TEXT NOT NULL,"
868 " author VARCHAR(255) NOT NULL,"
869 " date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',"
870 " time INT NOT NULL,"
871 " rating VARCHAR(255) NOT NULL,"
872 " filesize BIGINT NOT NULL,"
873 " player VARCHAR(255) NOT NULL,"
874 " playerargs TEXT NOT NULL,"
875 " download VARCHAR(255) NOT NULL,"
876 " downloadargs TEXT NOT NULL,"
877 " width SMALLINT NOT NULL,"
878 " height SMALLINT NOT NULL,"
879 " language VARCHAR(128) NOT NULL,"
880 " podcast BOOL NOT NULL,"
881 " downloadable BOOL NOT NULL,"
882 " customhtml BOOL NOT NULL,"
883 " countries VARCHAR(255) NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;"
884 };
885  if (!performActualUpdate("MythTV", "DBSchemaVer",
886  updates, "1258", dbver))
887  return false;
888  }
889 
890  if (dbver == "1258")
891  {
892  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1259");
893 
894  MSqlQuery select(MSqlQuery::InitCon());
895  select.prepare("SELECT hostname, data FROM settings "
896  " WHERE value = 'IndividualMuteControl'");
897 
898  if (!select.exec())
899  {
900  MythDB::DBError("Unable to retrieve IndividualMuteControl values.",
901  select);
902  return false;
903  }
904 
905  MSqlQuery update(MSqlQuery::InitCon());
906  while (select.next())
907  {
908  QString hostname = select.value(0).toString();
909  QString individual_mute = select.value(1).toString();
910 
911  if ("1" == individual_mute)
912  {
913  update.prepare("DELETE FROM keybindings "
914  " WHERE action = 'CYCLEAUDIOCHAN' AND "
915  " hostname = :HOSTNAME AND "
916  " context IN ('TV Frontend', "
917  " 'TV Playback')");
918 
919  update.bindValue(":HOSTNAME", hostname);
920 
921  if (!update.exec())
922  {
923  MythDB::DBError("Unable to update keybindings",
924  update);
925  return false;
926  }
927 
928  update.prepare("UPDATE keybindings "
929  " SET action = 'CYCLEAUDIOCHAN', "
930  " description = 'Cycle audio channels'"
931  " WHERE action = 'MUTE' AND "
932  " hostname = :HOSTNAME AND "
933  " context IN ('TV Frontend', "
934  " 'TV Playback')");
935 
936  update.bindValue(":HOSTNAME", hostname);
937 
938  if (!update.exec())
939  {
940  MythDB::DBError("Unable to update keybindings",
941  update);
942  return false;
943  }
944 
945  update.prepare("REPLACE INTO keybindings "
946  " VALUES (:CONTEXT, 'MUTE', 'Mute', "
947  " '', :HOSTNAME)");
948 
949  update.bindValue(":CONTEXT", "TV Playback");
950  update.bindValue(":HOSTNAME", hostname);
951  if (!update.exec())
952  {
953  MythDB::DBError("Unable to update keybindings",
954  update);
955  return false;
956  }
957  update.bindValue(":CONTEXT", "TV Frontend");
958  update.bindValue(":HOSTNAME", hostname);
959  if (!update.exec())
960  {
961  MythDB::DBError("Unable to update keybindings",
962  update);
963  return false;
964  }
965 
966  }
967  }
968 
969  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1259", dbver))
970  return false;
971  }
972 
973  if (dbver == "1259")
974  {
975  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1260");
976 
977  MSqlQuery query(MSqlQuery::InitCon());
978  query.prepare("DELETE FROM keybindings WHERE "
979  "action IN ('PAGEUP','PAGEDOWN') AND "
980  "context = 'TV FRONTEND'");
981  if (!query.exec())
982  {
983  MythDB::DBError("Unable to update keybindings", query);
984  return false;
985  }
986 
987  query.prepare("SELECT data FROM settings "
988  " WHERE value = 'EPGEnableJumpToChannel'");
989 
990  if (!query.exec())
991  {
992  MythDB::DBError("Unable to retrieve EPGEnableJumpToChannel values.",
993  query);
994  return false;
995  }
996 
997  MSqlQuery bindings(MSqlQuery::InitCon());
998  while (query.next())
999  {
1000  QString EPGEnableJumpToChannel = query.value(0).toString();
1001 
1002  if ("1" == EPGEnableJumpToChannel)
1003  {
1004  bindings.prepare("SELECT action, context, hostname, keylist "
1005  " FROM keybindings "
1006  " WHERE action IN ('DAYLEFT', "
1007  " 'DAYRIGHT', 'TOGGLEEPGORDER') AND "
1008  " context IN ('TV Frontend', "
1009  " 'TV Playback')");
1010 
1011  if (!bindings.exec())
1012  {
1013  MythDB::DBError("Unable to update keybindings",
1014  bindings);
1015  return false;
1016  }
1017  while (bindings.next())
1018  {
1019  QString action = bindings.value(0).toString();
1020  QString context = bindings.value(1).toString();
1021  QString hostname = bindings.value(2).toString();
1022  QStringList oldKeylist = bindings.value(3).toString().split(',');
1023  QStringList newKeyList;
1024 
1025  QStringList::iterator it;
1026  for (it = oldKeylist.begin(); it != oldKeylist.end();++it)
1027  {
1028  bool ok = false;
1029  int num = (*it).toInt(&ok);
1030  if (!ok && num >= 0 && num <= 9)
1031  newKeyList << (*it);
1032  }
1033  QString keyList = newKeyList.join(",");
1034 
1035  MSqlQuery update(MSqlQuery::InitCon());
1036  update.prepare("UPDATE keybindings "
1037  " SET keylist = :KEYLIST "
1038  " WHERE action = :ACTION "
1039  " AND context = :CONTEXT "
1040  " AND hostname = :HOSTNAME");
1041 
1042  update.bindValue(":KEYLIST", keyList);
1043  update.bindValue(":ACTION", action);
1044  update.bindValue(":CONTEXT", context);
1045  update.bindValue(":HOSTNAME", hostname);
1046 
1047  if (!update.exec())
1048  {
1049  MythDB::DBError("Unable to update keybindings",
1050  update);
1051  return false;
1052  }
1053  }
1054  }
1055  }
1056 
1057  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1260", dbver))
1058  return false;
1059  }
1060 
1061  if (dbver == "1260")
1062  {
1063  if (gCoreContext->GetBoolSetting("MythFillFixProgramIDsHasRunOnce", false))
1064  {
1065  LOG(VB_GENERAL, LOG_CRIT,
1066  "Upgrading to MythTV schema version 1261");
1067  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1261", dbver))
1068  return false;
1069  }
1070  else
1071  {
1072 
1073  DBUpdates updates {
1074 "UPDATE recorded SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
1075 " SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
1076 "UPDATE oldrecorded SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
1077 " SUBSTRING(programid, 3)) WHERE length(programid) = 12;",
1078 "UPDATE program SET programid=CONCAT(SUBSTRING(programid, 1, 2), '00', "
1079 " SUBSTRING(programid, 3)) WHERE length(programid) = 12;"
1080 };
1081  if (!performActualUpdate("MythTV", "DBSchemaVer",
1082  updates, "1261", dbver))
1083  return false;
1084  }
1085  }
1086 
1087  if (dbver == "1261")
1088  {
1089  DBUpdates updates {
1090 "UPDATE program SET description = '' WHERE description IS NULL;",
1091 "UPDATE record SET description = '' WHERE description IS NULL;",
1092 "UPDATE recorded SET description = '' WHERE description IS NULL;",
1093 "UPDATE recordedprogram SET description = '' WHERE description IS NULL;",
1094 "UPDATE oldrecorded SET description = '' WHERE description IS NULL;",
1095 "UPDATE mythlog SET details = '' WHERE details IS NULL;",
1096 "UPDATE settings SET data = '' WHERE data IS NULL;",
1097 "UPDATE powerpriority SET selectclause = '' WHERE selectclause IS NULL;",
1098 "UPDATE customexample SET fromclause = '' WHERE fromclause IS NULL;",
1099 "UPDATE customexample SET whereclause = '' WHERE whereclause IS NULL;",
1100 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1101 "ALTER TABLE program MODIFY COLUMN description VARCHAR(16000) "
1102 " NOT NULL default '';",
1103 "ALTER TABLE record MODIFY COLUMN description VARCHAR(16000) "
1104 " NOT NULL default '';",
1105 "ALTER TABLE recorded MODIFY COLUMN description VARCHAR(16000) "
1106 " NOT NULL default '';",
1107 "ALTER TABLE recordedprogram MODIFY COLUMN description VARCHAR(16000) "
1108 " NOT NULL default '';",
1109 "ALTER TABLE oldrecorded MODIFY COLUMN description VARCHAR(16000) "
1110 " NOT NULL default '';",
1111 "ALTER TABLE mythlog MODIFY COLUMN details VARCHAR(16000) "
1112 " NOT NULL default '';",
1113 "ALTER TABLE settings MODIFY COLUMN data VARCHAR(16000) "
1114 " NOT NULL default '';",
1115 "ALTER TABLE powerpriority MODIFY COLUMN selectclause VARCHAR(16000) "
1116 " NOT NULL default '';",
1117 "ALTER TABLE customexample MODIFY COLUMN fromclause VARCHAR(10000) "
1118 " NOT NULL default '';",
1119 "ALTER TABLE customexample MODIFY COLUMN whereclause VARCHAR(10000) "
1120 " NOT NULL default '';"
1121 };
1122  if (!performActualUpdate("MythTV", "DBSchemaVer",
1123  updates, "1262", dbver))
1124  return false;
1125  }
1126 
1127  if (dbver == "1262")
1128  {
1129  DBUpdates updates {
1130 "INSERT INTO recgrouppassword (recgroup, password) SELECT 'All Programs',data FROM settings WHERE value='AllRecGroupPassword' LIMIT 1;",
1131 "DELETE FROM settings WHERE value='AllRecGroupPassword';"
1132 };
1133  if (!performActualUpdate("MythTV", "DBSchemaVer",
1134  updates, "1263", dbver))
1135  return false;
1136  }
1137 
1138  if (dbver == "1263")
1139  {
1140  DBUpdates updates {
1141 "UPDATE settings SET hostname = NULL WHERE value='ISO639Language0' AND data != 'aar' AND hostname IS NOT NULL LIMIT 1;",
1142 "UPDATE settings SET hostname = NULL WHERE value='ISO639Language1' AND data != 'aar' AND hostname IS NOT NULL LIMIT 1;",
1143 "DELETE FROM settings WHERE value='ISO639Language0' AND hostname IS NOT NULL;",
1144 "DELETE FROM settings WHERE value='ISO639Language1' AND hostname IS NOT NULL;"
1145 };
1146  if (!performActualUpdate("MythTV", "DBSchemaVer",
1147  updates, "1264", dbver))
1148  return false;
1149  }
1150 
1151  if (dbver == "1264")
1152  {
1153  DBUpdates updates {
1154 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1155 "DELETE FROM displayprofiles WHERE profilegroupid IN "
1156 " (SELECT profilegroupid FROM displayprofilegroups "
1157 " WHERE name IN ('CPU++', 'CPU+', 'CPU--'))",
1158 "DELETE FROM displayprofilegroups WHERE name IN ('CPU++', 'CPU+', 'CPU--')",
1159 "DELETE FROM settings WHERE value = 'DefaultVideoPlaybackProfile' "
1160 " AND data IN ('CPU++', 'CPU+', 'CPU--')",
1161 "UPDATE displayprofiles SET data = 'ffmpeg' WHERE data = 'libmpeg2'",
1162 "UPDATE displayprofiles SET data = 'ffmpeg' WHERE data = 'xvmc'",
1163 "UPDATE displayprofiles SET data = 'xv-blit' WHERE data = 'xvmc-blit'",
1164 "UPDATE displayprofiles SET data = 'softblend' WHERE data = 'ia44blend'"
1165 };
1166  if (!performActualUpdate("MythTV", "DBSchemaVer",
1167  updates, "1265", dbver))
1168  return false;
1169  }
1170 
1171  if (dbver == "1265")
1172  {
1173  DBUpdates updates {
1174 "ALTER TABLE dtv_multiplex MODIFY COLUMN updatetimestamp "
1175 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;",
1176 "ALTER TABLE dvdbookmark MODIFY COLUMN `timestamp` "
1177 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;",
1178 "ALTER TABLE jobqueue MODIFY COLUMN statustime "
1179 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;",
1180 "ALTER TABLE recorded MODIFY COLUMN lastmodified "
1181 " TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;"
1182 };
1183  if (!performActualUpdate("MythTV", "DBSchemaVer",
1184  updates, "1266", dbver))
1185  return false;
1186  }
1187 
1188  if (dbver == "1266")
1189  {
1191  return false;
1192 
1193  DBUpdates updates {
1194 "DELETE FROM settings WHERE value = 'mythvideo.DBSchemaVer'"
1195 };
1196  if (!performActualUpdate("MythTV", "DBSchemaVer",
1197  updates, "1267", dbver))
1198  return false;
1199  }
1200 
1201  if (dbver == "1267")
1202  {
1203  DBUpdates updates {
1204 "ALTER TABLE channel MODIFY xmltvid VARCHAR(255) NOT NULL DEFAULT '';"
1205 };
1206  if (!performActualUpdate("MythTV", "DBSchemaVer",
1207  updates, "1268", dbver))
1208  return false;
1209  }
1210 
1211  if (dbver == "1268")
1212  {
1213 
1214  DBUpdates updates {
1215 "DELETE FROM keybindings WHERE action='PREVSOURCE' AND keylist='Ctrl+Y';"
1216 };
1217  if (!performActualUpdate("MythTV", "DBSchemaVer",
1218  updates, "1269", dbver))
1219  return false;
1220  }
1221 
1222  if (dbver == "1269")
1223  {
1224  DBUpdates updates {
1225 "DELETE FROM profilegroups WHERE id >= 15;",
1226 "DELETE FROM recordingprofiles WHERE profilegroup >= 15;",
1227 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1228 "INSERT INTO profilegroups SET id = '15', name = 'ASI Recorder (DVEO)',"
1229 " cardtype = 'ASI', is_default = 1;",
1230 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 15;",
1231 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 15;",
1232 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 15;",
1233 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 15;",
1234 "INSERT INTO profilegroups SET id = '16', name = 'OCUR Recorder (CableLabs)',"
1235 " cardtype = 'OCUR', is_default = 1;",
1236 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 16;",
1237 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 16;",
1238 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 16;",
1239 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 16;"
1240 };
1241  if (!performActualUpdate("MythTV", "DBSchemaVer",
1242  updates, "1270", dbver))
1243  return false;
1244  }
1245 
1246  if (dbver == "1270")
1247  {
1248  DBUpdates updates {
1249 "ALTER TABLE oldrecorded ADD future TINYINT(1) NOT NULL DEFAULT 0;",
1250 "UPDATE oldrecorded SET future=0;"
1251 };
1252  if (!performActualUpdate("MythTV", "DBSchemaVer",
1253  updates, "1271", dbver))
1254  return false;
1255  }
1256 
1257  if (dbver == "1271")
1258  {
1259  DBUpdates updates {
1260 "ALTER TABLE recordmatch MODIFY recordid INT UNSIGNED NOT NULL;",
1261 "ALTER TABLE recordmatch MODIFY chanid INT UNSIGNED NOT NULL;",
1262 "ALTER TABLE recordmatch MODIFY starttime DATETIME NOT NULL;",
1263 "ALTER TABLE recordmatch MODIFY manualid INT UNSIGNED NOT NULL;",
1264 "ALTER TABLE recordmatch ADD INDEX (starttime, chanid);",
1265 "ALTER TABLE oldrecorded MODIFY generic TINYINT(1) NOT NULL;",
1266 "ALTER TABLE oldrecorded ADD INDEX (future);",
1267 "ALTER TABLE oldrecorded ADD INDEX (starttime, chanid);"
1268 };
1269  if (!performActualUpdate("MythTV", "DBSchemaVer",
1270  updates, "1272", dbver))
1271  return false;
1272  }
1273 
1274  if (dbver == "1272")
1275  {
1276  DBUpdates updates {
1277 "DROP INDEX starttime ON recordmatch;",
1278 "DROP INDEX starttime ON oldrecorded;",
1279 "ALTER TABLE recordmatch ADD INDEX (chanid, starttime, manualid);",
1280 "ALTER TABLE oldrecorded ADD INDEX (chanid, starttime);"
1281 };
1282  if (!performActualUpdate("MythTV", "DBSchemaVer",
1283  updates, "1273", dbver))
1284  return false;
1285  }
1286 
1287  if (dbver == "1273")
1288  {
1289  DBUpdates updates {
1290 "ALTER TABLE internetcontent MODIFY COLUMN updated "
1291 " DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';",
1292 "ALTER TABLE internetcontentarticles MODIFY COLUMN `date` "
1293 " DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';"
1294 };
1295 
1296  if (!performActualUpdate("MythTV", "DBSchemaVer",
1297  updates, "1274", dbver))
1298  return false;
1299  }
1300 
1301  if (dbver == "1274")
1302  {
1303  DBUpdates updates {
1304 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1305 "UPDATE cardinput SET tunechan=NULL"
1306 " WHERE inputname='DVBInput' OR inputname='MPEG2TS';"
1307 "UPDATE dtv_multiplex SET symbolrate = NULL"
1308 " WHERE modulation LIKE 't%' OR modulation LIKE '%t';",
1309 "UPDATE dtv_multiplex"
1310 " SET bandwidth=SUBSTR(modulation,2,1)"
1311 " WHERE SUBSTR(modulation,3,3)='qam' OR"
1312 " SUBSTR(modulation,3,4)='qpsk';",
1313 "UPDATE dtv_multiplex"
1314 " SET bandwidth=SUBSTR(modulation,5,1)"
1315 " WHERE SUBSTR(modulation,1,4)='auto' AND"
1316 " LENGTH(modulation)=6;",
1317 "UPDATE dtv_multiplex SET modulation='auto'"
1318 " WHERE modulation LIKE 'auto%';",
1319 "UPDATE dtv_multiplex SET modulation='qam_16'"
1320 " WHERE modulation LIKE '%qam16%';",
1321 "UPDATE dtv_multiplex SET modulation='qam_32'"
1322 " WHERE modulation LIKE '%qam32%';",
1323 "UPDATE dtv_multiplex SET modulation='qam_64'"
1324 " WHERE modulation LIKE '%qam64%';",
1325 "UPDATE dtv_multiplex SET modulation='qam_128'"
1326 " WHERE modulation LIKE '%qam128%';",
1327 "UPDATE dtv_multiplex SET modulation='qam_256'"
1328 " WHERE modulation LIKE '%qam256%';"
1329 };
1330  if (!performActualUpdate("MythTV", "DBSchemaVer",
1331  updates, "1275", dbver))
1332  return false;
1333  }
1334 
1335  if (dbver == "1275")
1336  {
1337  DBUpdates updates {
1338 "DROP TABLE IF EXISTS `logging`;",
1339 "CREATE TABLE `logging` ( "
1340 " `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, "
1341 " `host` varchar(64) NOT NULL, "
1342 " `application` varchar(64) NOT NULL, "
1343 " `pid` int(11) NOT NULL, "
1344 " `thread` varchar(64) NOT NULL, "
1345 " `msgtime` datetime NOT NULL, "
1346 " `level` int(11) NOT NULL, "
1347 " `message` varchar(2048) NOT NULL, "
1348 " PRIMARY KEY (`id`), "
1349 " KEY `host` (`host`,`application`,`pid`,`msgtime`), "
1350 " KEY `msgtime` (`msgtime`), "
1351 " KEY `level` (`level`) "
1352 ") ENGINE=MyISAM DEFAULT CHARSET=utf8; "
1353 };
1354  if (!performActualUpdate("MythTV", "DBSchemaVer",
1355  updates, "1276", dbver))
1356  return false;
1357  }
1358 
1359  if (dbver == "1276")
1360  {
1361  DBUpdates updates {
1362 "ALTER TABLE record ADD COLUMN filter INT UNSIGNED NOT NULL DEFAULT 0;",
1363 "CREATE TABLE IF NOT EXISTS recordfilter ("
1364 " filterid INT UNSIGNED NOT NULL PRIMARY KEY,"
1365 " description VARCHAR(64) DEFAULT NULL,"
1366 " clause VARCHAR(256) DEFAULT NULL,"
1367 " newruledefault TINYINT(1) DEFAULT 0) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
1368 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1369 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1370 " VALUES (0, 'New episode', 'program.previouslyshown = 0', 0);",
1371 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1372 " VALUES (1, 'Identifiable episode', 'program.generic = 0', 0);",
1373 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1374 " VALUES (2, 'First showing', 'program.first > 0', 0);",
1375 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1376 " VALUES (3, 'Primetime', 'HOUR(program.starttime) >= 19 AND HOUR(program.starttime) < 23', 0);",
1377 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1378 " VALUES (4, 'Commercial free', 'channel.commmethod = -2', 0);",
1379 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1380 " VALUES (5, 'High definition', 'program.hdtv > 0', 0);"
1381 };
1382 
1383  if (!performActualUpdate("MythTV", "DBSchemaVer",
1384  updates, "1277", dbver))
1385  return false;
1386  }
1387 
1388  if (dbver == "1277")
1389  {
1390  DBUpdates updates {
1391 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1392 "ALTER TABLE record ADD autometadata TINYINT(1) NOT NULL DEFAULT "
1393 " 0 AFTER autouserjob4;",
1394 "ALTER TABLE record ADD inetref VARCHAR(40) NOT NULL AFTER programid;",
1395 "ALTER TABLE record ADD season SMALLINT(5) NOT NULL AFTER description;",
1396 "ALTER TABLE record ADD episode SMALLINT(5) NOT NULL AFTER season;",
1397 "ALTER TABLE recorded ADD inetref VARCHAR(40) NOT NULL AFTER programid;",
1398 "ALTER TABLE recorded ADD season SMALLINT(5) NOT NULL AFTER description;",
1399 "ALTER TABLE recorded ADD episode SMALLINT(5) NOT NULL AFTER season;",
1400 "ALTER TABLE oldrecorded ADD inetref VARCHAR(40) NOT NULL AFTER programid;",
1401 "ALTER TABLE oldrecorded ADD season SMALLINT(5) NOT NULL AFTER description;",
1402 "ALTER TABLE oldrecorded ADD episode SMALLINT(5) NOT NULL AFTER season;"
1403 };
1404  if (!performActualUpdate("MythTV", "DBSchemaVer",
1405  updates, "1278", dbver))
1406  return false;
1407  }
1408 
1409  if (dbver == "1278")
1410  {
1411  DBUpdates updates {
1412 "CREATE TABLE recordedartwork ( "
1413 " inetref VARCHAR(255) NOT NULL, "
1414 " season SMALLINT(5) NOT NULL, "
1415 " host TEXT NOT NULL, "
1416 " coverart TEXT NOT NULL, "
1417 " fanart TEXT NOT NULL, "
1418 " banner TEXT NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;"
1419 };
1420  if (!performActualUpdate("MythTV", "DBSchemaVer",
1421  updates, "1279", dbver))
1422  return false;
1423  }
1424 
1425  if (dbver == "1279")
1426  {
1427  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1280");
1428 
1429  MSqlQuery select(MSqlQuery::InitCon());
1430  // New DBs/hosts will not have a NoPromptOnExit, so they'll get defaults
1431  select.prepare("SELECT hostname, data FROM settings "
1432  " WHERE value = 'NoPromptOnExit'");
1433  if (!select.exec())
1434  {
1435  MythDB::DBError("Unable to retrieve confirm exit values.", select);
1436  }
1437  else
1438  {
1439  MSqlQuery update(MSqlQuery::InitCon());
1440  while (select.next())
1441  {
1442  QString hostname = select.value(0).toString();
1443  // Yes, enabled NoPromptOnExit meant to prompt on exit
1444  QString prompt_on_exit = select.value(1).toString();
1445  // Default EXITPROMPT is wrong for all upgrades
1446  update.prepare("DELETE FROM keybindings "
1447  " WHERE action = 'EXITPROMPT' "
1448  " AND context = 'Main Menu' "
1449  " AND hostname = :HOSTNAME ;");
1450  update.bindValue(":HOSTNAME", hostname);
1451  if (!update.exec())
1452  MythDB::DBError("Unable to delete EXITPROMPT binding",
1453  update);
1454 
1455  if ("0" == prompt_on_exit)
1456  {
1457  // EXIT is already mapped appropriately, so just create a
1458  // no-keylist mapping for EXITPROMPT to prevent conflict
1459  update.prepare("INSERT INTO keybindings (context, action, "
1460  " description, keylist, hostname) "
1461  "VALUES ('Main Menu', 'EXITPROMPT', '', "
1462  " '', :HOSTNAME );");
1463  update.bindValue(":HOSTNAME", hostname);
1464  if (!update.exec())
1465  MythDB::DBError("Unable to create EXITPROMPT binding",
1466  update);
1467  }
1468  else
1469  {
1470  // EXIT must be changed to EXITPROMPT
1471  update.prepare("UPDATE keybindings "
1472  " SET action = 'EXITPROMPT' "
1473  " WHERE action = 'EXIT' "
1474  " AND context = 'Main Menu' "
1475  " AND hostname = :HOSTNAME ;");
1476  update.bindValue(":HOSTNAME", hostname);
1477  if (!update.exec())
1478  MythDB::DBError("Unable to update EXITPROMPT binding",
1479  update);
1480  }
1481  }
1482  }
1483 
1484  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1280", dbver))
1485  return false;
1486  }
1487 
1488  if (dbver == "1280")
1489  {
1490  DBUpdates updates {
1491 "ALTER TABLE program ADD INDEX (subtitle);",
1492 "ALTER TABLE program ADD INDEX (description(255));",
1493 "ALTER TABLE oldrecorded ADD INDEX (subtitle);",
1494 "ALTER TABLE oldrecorded ADD INDEX (description(255));"
1495 };
1496  if (!performActualUpdate("MythTV", "DBSchemaVer",
1497  updates, "1281", dbver))
1498  return false;
1499  }
1500 
1501  if (dbver == "1281")
1502  {
1503  DBUpdates updates {
1504 "ALTER TABLE cardinput ADD changer_device VARCHAR(128) "
1505 "AFTER externalcommand;",
1506 "ALTER TABLE cardinput ADD changer_model VARCHAR(128) "
1507 "AFTER changer_device;"
1508 };
1509  if (!performActualUpdate("MythTV", "DBSchemaVer",
1510  updates, "1282", dbver))
1511  return false;
1512  }
1513 
1514  if (dbver == "1282")
1515  {
1516  DBUpdates updates {
1517 "UPDATE settings"
1518 " SET data = SUBSTR(data, INSTR(data, 'share/mythtv/metadata')+13)"
1519 " WHERE value "
1520 " IN ('TelevisionGrabber', "
1521 " 'MovieGrabber', "
1522 " 'mythgame.MetadataGrabber');"
1523 };
1524 
1525  if (!performActualUpdate("MythTV", "DBSchemaVer",
1526  updates, "1283", dbver))
1527  return false;
1528  }
1529 
1530  if (dbver == "1283")
1531  {
1532  DBUpdates updates {
1533 "UPDATE record SET filter = filter | 1 WHERE record.dupin & 0x20",
1534 "UPDATE record SET filter = filter | 2 WHERE record.dupin & 0x40",
1535 "UPDATE record SET filter = filter | 5 WHERE record.dupin & 0x80",
1536 "UPDATE record SET dupin = dupin & ~0xe0",
1537 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1538 "INSERT INTO recordfilter (filterid, description, clause, newruledefault) "
1539 " 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);"
1540 };
1541 
1542  if (!performActualUpdate("MythTV", "DBSchemaVer",
1543  updates, "1284", dbver))
1544  return false;
1545  }
1546 
1547  if (dbver == "1284")
1548  {
1549  DBUpdates updates {
1550 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
1551 " 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);"
1552 };
1553 
1554  if (!performActualUpdate("MythTV", "DBSchemaVer",
1555  updates, "1285", dbver))
1556  return false;
1557  }
1558 
1559  if (dbver == "1285")
1560  {
1561  DBUpdates updates {
1562 "DELETE FROM profilegroups WHERE id >= 17;",
1563 "DELETE FROM recordingprofiles WHERE profilegroup >= 17;",
1564 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1565 "INSERT INTO profilegroups SET id = '17', name = 'Ceton Recorder',"
1566 " cardtype = 'CETON', is_default = 1;",
1567 "INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = 17;",
1568 "INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = 17;",
1569 "INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = 17;",
1570 "INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = 17;"
1571 };
1572  if (!performActualUpdate("MythTV", "DBSchemaVer",
1573  updates, "1286", dbver))
1574  return false;
1575  }
1576 
1577  if (dbver == "1286")
1578  {
1579  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1287");
1580  MSqlQuery query(MSqlQuery::InitCon());
1581  query.prepare("SELECT cardid, videodevice "
1582  "FROM capturecard "
1583  "WHERE cardtype='CETON'");
1584  if (!query.exec())
1585  {
1586  LOG(VB_GENERAL, LOG_ERR,
1587  "Unable to query capturecard table for upgrade to 1287.");
1588  return false;
1589  }
1590 
1591  MSqlQuery update(MSqlQuery::InitCon());
1592  update.prepare("UPDATE capturecard SET videodevice=:VIDDEV "
1593  "WHERE cardid=:CARDID");
1594  while (query.next())
1595  {
1596  uint cardid = query.value(0).toUInt();
1597  QString videodevice = query.value(1).toString();
1598  QStringList parts = videodevice.split("-");
1599  if (parts.size() != 2)
1600  {
1601  LOG(VB_GENERAL, LOG_ERR,
1602  "Unable to parse videodevice in upgrade to 1287.");
1603  return false;
1604  }
1605  if (parts[1].contains("."))
1606  continue; // already in new format, skip it..
1607 
1608  int input = std::max(parts[1].toInt() - 1, 0);
1609  videodevice = parts[0] + QString("-0.%1").arg(input);
1610  update.bindValue(":CARDID", cardid);
1611  update.bindValue(":VIDDEV", videodevice);
1612  if (!update.exec())
1613  {
1614  LOG(VB_GENERAL, LOG_ERR,
1615  "Failed to update videodevice in upgrade to 1287.");
1616  return false;
1617  }
1618  }
1619 
1620  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1287", dbver))
1621  return false;
1622  }
1623 
1624  if (dbver == "1287")
1625  {
1626  DBUpdates updates {
1627 "CREATE TABLE IF NOT EXISTS livestream ( "
1628 " id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, "
1629 " width INT UNSIGNED NOT NULL, "
1630 " height INT UNSIGNED NOT NULL, "
1631 " bitrate INT UNSIGNED NOT NULL, "
1632 " audiobitrate INT UNSIGNED NOT NULL, "
1633 " samplerate INT UNSIGNED NOT NULL, "
1634 " audioonlybitrate INT UNSIGNED NOT NULL, "
1635 " segmentsize INT UNSIGNED NOT NULL DEFAULT 10, "
1636 " maxsegments INT UNSIGNED NOT NULL DEFAULT 0, "
1637 " startsegment INT UNSIGNED NOT NULL DEFAULT 0, "
1638 " currentsegment INT UNSIGNED NOT NULL DEFAULT 0, "
1639 " segmentcount INT UNSIGNED NOT NULL DEFAULT 0, "
1640 " percentcomplete INT UNSIGNED NOT NULL DEFAULT 0, "
1641 " created DATETIME NOT NULL, "
1642 " lastmodified DATETIME NOT NULL, "
1643 " relativeurl VARCHAR(512) NOT NULL, "
1644 " fullurl VARCHAR(1024) NOT NULL, "
1645 " status INT UNSIGNED NOT NULL DEFAULT 0, "
1646 " statusmessage VARCHAR(256) NOT NULL, "
1647 " sourcefile VARCHAR(512) NOT NULL, "
1648 " sourcehost VARCHAR(64) NOT NULL, "
1649 " sourcewidth INT UNSIGNED NOT NULL DEFAULT 0, "
1650 " sourceheight INT UNSIGNED NOT NULL DEFAULT 0, "
1651 " outdir VARCHAR(256) NOT NULL, "
1652 " outbase VARCHAR(128) NOT NULL "
1653 ") ENGINE=MyISAM DEFAULT CHARSET=utf8; "
1654 };
1655 
1656  if (!performActualUpdate("MythTV", "DBSchemaVer",
1657  updates, "1288", dbver))
1658  return false;
1659  }
1660 
1661  if (dbver == "1288")
1662  {
1663  DBUpdates updates {
1664 "ALTER TABLE recordedprogram CHANGE COLUMN videoprop videoprop "
1665 " SET('HDTV', 'WIDESCREEN', 'AVC', '720', '1080', 'DAMAGED') NOT NULL; "
1666 };
1667  if (!performActualUpdate("MythTV", "DBSchemaVer",
1668  updates, "1289", dbver))
1669  return false;
1670  }
1671 
1672  if (dbver == "1289")
1673  {
1674  DBUpdates updates {
1675 "DROP TABLE IF EXISTS netvisionrssitems;",
1676 "DROP TABLE IF EXISTS netvisionsearchgrabbers;",
1677 "DROP TABLE IF EXISTS netvisionsites;",
1678 "DROP TABLE IF EXISTS netvisiontreegrabbers;",
1679 "DROP TABLE IF EXISTS netvisiontreeitems;"
1680 };
1681 
1682  if (!performActualUpdate("MythTV", "DBSchemaVer",
1683  updates, "1290", dbver))
1684  return false;
1685  }
1686 
1687  if (dbver == "1290")
1688  {
1689  DBUpdates updates {
1690 "ALTER TABLE logging "
1691 " ALTER COLUMN host SET DEFAULT '', "
1692 " ALTER COLUMN application SET DEFAULT '', "
1693 " ALTER COLUMN pid SET DEFAULT '0', "
1694 " ALTER COLUMN thread SET DEFAULT '', "
1695 " ALTER COLUMN level SET DEFAULT '0';",
1696 "ALTER TABLE logging "
1697 " ADD COLUMN tid INT(11) NOT NULL DEFAULT '0' AFTER pid, "
1698 " ADD COLUMN filename VARCHAR(255) NOT NULL DEFAULT '' AFTER thread, "
1699 " ADD COLUMN line INT(11) NOT NULL DEFAULT '0' AFTER filename, "
1700 " ADD COLUMN `function` VARCHAR(255) NOT NULL DEFAULT '' AFTER line;"
1701 };
1702 
1703  if (!performActualUpdate("MythTV", "DBSchemaVer",
1704  updates, "1291", dbver))
1705  return false;
1706  }
1707 
1708  if (dbver == "1291")
1709  {
1710  DBUpdates updates {
1711 "UPDATE recorded r, recordedprogram rp SET r.duplicate=0 "
1712 " WHERE r.chanid=rp.chanid AND r.progstart=rp.starttime AND "
1713 " FIND_IN_SET('DAMAGED', rp.videoprop);"
1714 };
1715 
1716  if (!performActualUpdate("MythTV", "DBSchemaVer",
1717  updates, "1292", dbver))
1718  return false;
1719  }
1720 
1721  if (dbver == "1292")
1722  {
1723  DBUpdates updates {
1724 "ALTER TABLE cardinput "
1725 " ADD COLUMN schedorder INT(10) UNSIGNED NOT NULL DEFAULT '0', "
1726 " ADD COLUMN livetvorder INT(10) UNSIGNED NOT NULL DEFAULT '0';",
1727 "UPDATE cardinput SET schedorder = cardinputid;",
1728 "UPDATE cardinput SET livetvorder = cardid;"
1729 };
1730 
1731  if (gCoreContext->GetBoolSetting("LastFreeCard", false))
1732  {
1733  updates[2] =
1734  "UPDATE cardinput SET livetvorder = "
1735  " (SELECT MAX(cardid) FROM capturecard) - cardid + 1;";
1736  }
1737 
1738  if (!performActualUpdate("MythTV", "DBSchemaVer",
1739  updates, "1293", dbver))
1740  return false;
1741  }
1742 
1743  if (dbver == "1293")
1744  {
1745  DBUpdates updates {
1746 "TRUNCATE TABLE recordmatch",
1747 "ALTER TABLE recordmatch DROP INDEX recordid",
1748 "ALTER TABLE recordmatch ADD UNIQUE INDEX (recordid, chanid, starttime)",
1749 "UPDATE recordfilter SET description='Prime time' WHERE filterid=3",
1750 "UPDATE recordfilter SET description='This episode' WHERE filterid=6",
1751 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
1752 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
1753 " VALUES (7, 'This series', '(RECTABLE.seriesid <> '''' AND program.seriesid = RECTABLE.seriesid)', 0);"
1754 };
1755 
1756  if (!performActualUpdate("MythTV", "DBSchemaVer",
1757  updates, "1294", dbver))
1758  return false;
1759  }
1760 
1761  if (dbver == "1294")
1762  {
1763  DBUpdates updates {
1764 "CREATE TABLE videocollection ("
1765 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
1766 " title varchar(256) NOT NULL,"
1767 " contenttype set('MOVIE', 'TELEVISION', 'ADULT', 'MUSICVIDEO', 'HOMEVIDEO') NOT NULL default '',"
1768 " plot text,"
1769 " network varchar(128) DEFAULT NULL,"
1770 " inetref varchar(128) NOT NULL,"
1771 " certification varchar(128) DEFAULT NULL,"
1772 " genre int(10) unsigned DEFAULT '0',"
1773 " releasedate date DEFAULT NULL,"
1774 " language varchar(10) DEFAULT NULL,"
1775 " status varchar(64) DEFAULT NULL,"
1776 " rating float DEFAULT 0,"
1777 " ratingcount int(10) DEFAULT 0,"
1778 " runtime smallint(5) unsigned DEFAULT '0',"
1779 " banner text,"
1780 " fanart text,"
1781 " coverart text,"
1782 " PRIMARY KEY (intid),"
1783 " KEY title (title)"
1784 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
1785 "CREATE TABLE videopathinfo ("
1786 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
1787 " path text,"
1788 " contenttype set('MOVIE', 'TELEVISION', 'ADULT', 'MUSICVIDEO', 'HOMEVIDEO') NOT NULL default '',"
1789 " collectionref int(10) default '0',"
1790 " recurse tinyint(1) default '0',"
1791 " PRIMARY KEY (intid)"
1792 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
1793 "ALTER TABLE videometadata ADD collectionref int(10) NOT NULL DEFAULT '0' AFTER inetref;",
1794 "ALTER TABLE videometadata ADD playcount int(10) NOT NULL DEFAULT '0' AFTER length;",
1795 "ALTER TABLE videometadata ADD contenttype set('MOVIE', 'TELEVISION', 'ADULT', 'MUSICVIDEO', 'HOMEVIDEO') NOT NULL default ''",
1796 "UPDATE videometadata SET contenttype = 'MOVIE';",
1797 "UPDATE videometadata SET contenttype = 'TELEVISION' WHERE season > 0 OR episode > 0;"
1798 };
1799 
1800  if (!performActualUpdate("MythTV", "DBSchemaVer",
1801  updates, "1295", dbver))
1802  return false;
1803  }
1804 
1805  if (dbver == "1295")
1806  {
1807  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1296");
1808  MSqlQuery query(MSqlQuery::InitCon());
1809  query.prepare("SELECT data, hostname "
1810  "FROM settings "
1811  "WHERE value='BackendServerIP'");
1812  if (!query.exec())
1813  {
1814  LOG(VB_GENERAL, LOG_ERR,
1815  "Unable to repair IP addresses for IPv4/IPv6 split.");
1816  return false;
1817  }
1818 
1819  MSqlQuery update(MSqlQuery::InitCon());
1820  MSqlQuery insert(MSqlQuery::InitCon());
1821  update.prepare("UPDATE settings "
1822  "SET data=:IP4ADDY "
1823  "WHERE value='BackendServerIP' "
1824  "AND hostname=:HOSTNAME");
1825  insert.prepare("INSERT INTO settings "
1826  "SET value='BackendServerIP6',"
1827  "data=:IP6ADDY,"
1828  "hostname=:HOSTNAME");
1829  while (query.next())
1830  {
1831  QHostAddress oldaddr(query.value(0).toString());
1832  QString hostname = query.value(1).toString();
1833 
1834  update.bindValue(":HOSTNAME", hostname);
1835  insert.bindValue(":HOSTNAME", hostname);
1836 
1837  if (oldaddr.protocol() == QAbstractSocket::IPv6Protocol)
1838  {
1839  update.bindValue(":IP4ADDY", "127.0.0.1");
1840  insert.bindValue(":IP6ADDY", query.value(0).toString());
1841  }
1842  else if (oldaddr.protocol() == QAbstractSocket::IPv4Protocol)
1843  {
1844  update.bindValue(":IP4ADDY", query.value(0).toString());
1845  insert.bindValue(":IP6ADDY", "::1");
1846  }
1847  else
1848  {
1849  update.bindValue(":IP4ADDY", "127.0.0.1");
1850  insert.bindValue(":IP6ADDY", "::1");
1851  LOG(VB_GENERAL, LOG_CRIT,
1852  QString("Invalid address string '%1' found on %2. "
1853  "Reverting to localhost defaults.")
1854  .arg(query.value(0).toString(), hostname));
1855  }
1856 
1857  if (!update.exec() || !insert.exec())
1858  {
1859  LOG(VB_GENERAL, LOG_ERR, QString("Failed to separate IPv4 "
1860  "and IPv6 addresses for %1").arg(hostname));
1861  return false;
1862  }
1863 
1864  }
1865 
1866  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1296", dbver))
1867  return false;
1868  }
1869 
1870  if (dbver == "1296")
1871  {
1872  DBUpdates updates {
1873 "ALTER TABLE videocollection CHANGE inetref collectionref "
1874 "VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci "
1875 "NOT NULL",
1876 "ALTER TABLE videocollection CHANGE genre genre VARCHAR(128) NULL DEFAULT ''"
1877 };
1878 
1879  if (!performActualUpdate("MythTV", "DBSchemaVer",
1880  updates, "1297", dbver))
1881  return false;
1882  }
1883 
1884  if (dbver == "1297")
1885  {
1886  DBUpdates updates {
1887 "ALTER TABLE videometadata CHANGE collectionref collectionref INT(10) "
1888 "NOT NULL DEFAULT -1",
1889 "UPDATE videometadata SET collectionref = '-1'"
1890 };
1891 
1892  if (!performActualUpdate("MythTV", "DBSchemaVer",
1893  updates, "1298", dbver))
1894  return false;
1895  }
1896 
1897  if (dbver == "1298")
1898  {
1899  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1299");
1900 
1901  // DeletedMaxAge setting only exists if the user ever triggered the
1902  // DeletedExpireOptions TriggeredConfigurationGroup (enabled
1903  // AutoExpireInsteadOfDelete) and changed DeletedMaxAge from its
1904  // default of zero, so "reset" it to ensure it's in the database before
1905  // the update
1906  QString deletedMaxAge = gCoreContext->GetSetting("DeletedMaxAge", "0");
1907  gCoreContext->SaveSettingOnHost("DeletedMaxAge", deletedMaxAge, nullptr);
1908 
1909  QString queryStr;
1910  if (gCoreContext->GetBoolSetting("AutoExpireInsteadOfDelete", false))
1911  {
1912  queryStr = "UPDATE settings SET data='-1' WHERE "
1913  "value='DeletedMaxAge' AND data='0'";
1914  }
1915  else
1916  {
1917  queryStr = "UPDATE settings SET data='0' WHERE "
1918  "value='DeletedMaxAge'";
1919  }
1920 
1921  MSqlQuery query(MSqlQuery::InitCon());
1922  query.prepare(queryStr);
1923  if (!query.exec())
1924  {
1925  MythDB::DBError("Could not perform update for '1299'", query);
1926  return false;
1927  }
1928 
1929  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1299", dbver))
1930  return false;
1931  }
1932 
1933  if (dbver == "1299")
1934  {
1935  DBUpdates updates {
1936 "ALTER TABLE recordmatch ADD COLUMN findid INT NOT NULL DEFAULT 0",
1937 "ALTER TABLE recordmatch ADD INDEX (recordid, findid)"
1938 };
1939 
1940  if (!performActualUpdate("MythTV", "DBSchemaVer",
1941  updates, "1300", dbver))
1942  return false;
1943  }
1944 
1945  if (dbver == "1300")
1946  {
1947  DBUpdates updates {
1948 "ALTER TABLE channel ADD COLUMN iptvid SMALLINT(6) UNSIGNED;",
1949 "CREATE TABLE iptv_channel ("
1950 " iptvid SMALLINT(6) UNSIGNED NOT NULL auto_increment,"
1951 " chanid INT(10) UNSIGNED NOT NULL,"
1952 " url TEXT NOT NULL,"
1953 " type set('data', "
1954 " 'rfc2733-1','rfc2733-2', "
1955 " 'rfc5109-1','rfc5109-2', "
1956 " 'smpte2022-1','smpte2022-2'),"
1957 " bitrate INT(10) UNSIGNED NOT NULL,"
1958 " PRIMARY KEY (iptvid)"
1959 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;"
1960 };
1961 
1962  if (!performActualUpdate("MythTV", "DBSchemaVer",
1963  updates, "1301", dbver))
1964  return false;
1965  }
1966 
1967  if (dbver == "1301")
1968  {
1969  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1302");
1970  // Create the Default recording rule template
1971  RecordingRule record;
1972  record.MakeTemplate("Default");
1973  record.m_type = kTemplateRecord;
1974  // Take some defaults from now obsoleted settings.
1975  record.m_startOffset =
1976  gCoreContext->GetNumSetting("DefaultStartOffset", 0);
1977  record.m_endOffset =
1978  gCoreContext->GetNumSetting("DefaultEndOffset", 0);
1979  record.m_dupMethod =
1980  static_cast<RecordingDupMethodType>(
1982  "prefDupMethod", kDupCheckSubDesc));
1984  record.m_autoExpire =
1985  gCoreContext->GetBoolSetting("AutoExpireDefault", false);
1986  record.m_autoCommFlag =
1987  gCoreContext->GetBoolSetting("AutoCommercialFlag", true);
1988  record.m_autoTranscode =
1989  gCoreContext->GetBoolSetting("AutoTranscode", false);
1990  record.m_transcoder =
1992  "DefaultTranscoder", static_cast<int>(RecordingProfile::kTranscoderAutodetect));
1993  record.m_autoUserJob1 =
1994  gCoreContext->GetBoolSetting("AutoRunUserJob1", false);
1995  record.m_autoUserJob2 =
1996  gCoreContext->GetBoolSetting("AutoRunUserJob2", false);
1997  record.m_autoUserJob3 =
1998  gCoreContext->GetBoolSetting("AutoRunUserJob3", false);
1999  record.m_autoUserJob4 =
2000  gCoreContext->GetBoolSetting("AutoRunUserJob4", false);
2001  record.m_autoMetadataLookup =
2002  gCoreContext->GetBoolSetting("AutoMetadataLookup", true);
2003  record.Save(false);
2004 
2005  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1302", dbver))
2006  return false;
2007  }
2008 
2009  if (dbver == "1302")
2010  {
2011  QDateTime loc = QDateTime::currentDateTime();
2012  QDateTime utc = loc.toUTC();
2013  loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
2014  int utc_offset = loc.secsTo(utc) / 60;
2015 
2016  QList<QByteArray> updates_ba;
2017 
2018  // Convert DATE and TIME in record into DATETIME
2019  const std::array<const std::string,2> pre_sql {
2020  "CREATE TEMPORARY TABLE recordupdate ("
2021  "recid INT, starttime DATETIME, endtime DATETIME)",
2022  "INSERT INTO recordupdate (recid, starttime, endtime) "
2023  "SELECT recordid, "
2024  " CONCAT(startdate, ' ', starttime), "
2025  " CONCAT(enddate, ' ', endtime) FROM record",
2026  };
2027  std::transform(pre_sql.cbegin(), pre_sql.cend(),
2028  std::back_inserter(updates_ba), ss2ba);
2029 
2030  // Convert various DATETIME fields from local time to UTC
2031  if (0 != utc_offset)
2032  {
2033  const std::array<const std::string,4> with_endtime {
2034  "program", "recorded", "oldrecorded", "recordupdate",
2035  };
2036  const std::array<const std::string,4> without_endtime {
2037  "programgenres", "programrating", "credits",
2038  "jobqueue",
2039  };
2040  order = (utc_offset > 0) ? "-starttime" : "starttime";
2041  std::transform(with_endtime.cbegin(), with_endtime.cend(),
2042  std::back_inserter(updates_ba), add_start_end);
2043  std::transform(without_endtime.cbegin(), without_endtime.cend(),
2044  std::back_inserter(updates_ba), add_start);
2045 
2046  updates_ba.push_back(
2047  QString("UPDATE oldprogram "
2048  "SET airdate = "
2049  " CONVERT_TZ(airdate, 'SYSTEM', 'Etc/UTC') "
2050  "ORDER BY %3")
2051  .arg((utc_offset > 0) ? "-airdate" :
2052  "airdate").toLocal8Bit());
2053 
2054  updates_ba.push_back(
2055  QString("UPDATE recorded "
2056  "set progstart = "
2057  " CONVERT_TZ(progstart, 'SYSTEM', 'Etc/UTC'), "
2058  " progend = "
2059  " CONVERT_TZ(progend, 'SYSTEM', 'Etc/UTC') ")
2060  .toLocal8Bit());
2061  }
2062 
2063  // Convert DATETIME back to separate DATE and TIME in record table
2064  const std::array<const std::string,2> post_sql {
2065  "UPDATE record, recordupdate "
2066  "SET record.startdate = DATE(recordupdate.starttime), "
2067  " record.starttime = TIME(recordupdate.starttime), "
2068  " record.enddate = DATE(recordupdate.endtime), "
2069  " record.endtime = TIME(recordupdate.endtime), "
2070  " record.last_record = "
2071  " CONVERT_TZ(last_record, 'SYSTEM', 'Etc/UTC'), "
2072  " record.last_delete = "
2073  " CONVERT_TZ(last_delete, 'SYSTEM', 'Etc/UTC') "
2074  "WHERE recordid = recid",
2075  "DROP TABLE recordupdate",
2076  };
2077 
2078  std::transform(post_sql.cbegin(), post_sql.cend(),
2079  std::back_inserter(updates_ba), ss2ba);
2080 
2081  // Convert update ByteArrays to NULL terminated char**
2082  DBUpdates updates;
2083  std::transform(updates_ba.cbegin(), updates_ba.cend(),
2084  std::back_inserter(updates), qs2ba);
2085 
2086  // do the actual update
2087  if (!performActualUpdate("MythTV", "DBSchemaVer",
2088  updates, "1303", dbver))
2089  return false;
2090  }
2091 
2092  if (dbver == "1303")
2093  {
2094  QDateTime loc = QDateTime::currentDateTime();
2095  QDateTime utc = loc.toUTC();
2096  loc = QDateTime(loc.date(), loc.time(), Qt::UTC);
2097  int utc_offset = loc.secsTo(utc) / 60;
2098 
2099  QList<QByteArray> updates_ba;
2100 
2101  // Convert various DATETIME fields from local time to UTC
2102  if (0 != utc_offset)
2103  {
2104  const std::array<const std::string,1> with_endtime = {
2105  "recordedprogram",
2106  };
2107  const std::array<const std::string,4> without_endtime = {
2108  "recordedseek", "recordedmarkup", "recordedrating",
2109  "recordedcredits",
2110  };
2111  order = (utc_offset > 0) ? "-starttime" : "starttime";
2112  std::transform(with_endtime.cbegin(), with_endtime.cend(),
2113  std::back_inserter(updates_ba), add_start_end);
2114  std::transform(without_endtime.cbegin(), without_endtime.cend(),
2115  std::back_inserter(updates_ba), add_start);
2116  }
2117 
2118  // Convert update ByteArrays to NULL terminated char**
2119  DBUpdates updates;
2120  std::transform(updates_ba.cbegin(), updates_ba.cend(),
2121  std::back_inserter(updates), qs2ba);
2122 
2123  // do the actual update
2124  if (!performActualUpdate("MythTV", "DBSchemaVer",
2125  updates, "1304", dbver))
2126  return false;
2127  }
2128 
2129  if (dbver == "1304")
2130  {
2131  QList<QByteArray> updates_ba;
2132 
2133  updates_ba.push_back(
2134 "UPDATE recordfilter SET clause="
2135 "'HOUR(CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM'')) >= 19 AND "
2136 "HOUR(CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM'')) < 22' "
2137 "WHERE filterid=3");
2138 
2139  updates_ba.push_back(QString(
2140 "UPDATE record SET findday = "
2141 " DAYOFWEEK(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2142 " 'SYSTEM', 'Etc/UTC') + INTERVAL findday DAY) "
2143 "WHERE findday > 0").toLocal8Bit());
2144 
2145  updates_ba.push_back(QString(
2146 "UPDATE record SET findtime = "
2147 " TIME(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2148 " 'SYSTEM', 'Etc/UTC')) ")
2149  .toLocal8Bit());
2150 
2151  // Convert update ByteArrays to NULL terminated char**
2152  DBUpdates updates;
2153  std::transform(updates_ba.cbegin(), updates_ba.cend(),
2154  std::back_inserter(updates), qs2ba);
2155 
2156  if (!performActualUpdate("MythTV", "DBSchemaVer",
2157  updates, "1305", dbver))
2158  return false;
2159  }
2160 
2161  if (dbver == "1305")
2162  {
2163  // Reverse the findday/findtime changes from above since those
2164  // values need to be kept in local time.
2165 
2166  QList<QByteArray> updates_ba;
2167 
2168  updates_ba.push_back(QString(
2169 "UPDATE record SET findday = "
2170 " DAYOFWEEK(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2171 " 'Etc/UTC', 'SYSTEM') + INTERVAL findday DAY) "
2172 "WHERE findday > 0").toLocal8Bit());
2173 
2174  updates_ba.push_back(QString(
2175 "UPDATE record SET findtime = "
2176 " TIME(CONVERT_TZ(ADDTIME('2012-06-02 00:00:00', findtime), "
2177 " 'Etc/UTC', 'SYSTEM')) ").toLocal8Bit());
2178 
2179  // Convert update ByteArrays to NULL terminated char**
2180  DBUpdates updates;
2181  std::transform(updates_ba.cbegin(), updates_ba.cend(),
2182  std::back_inserter(updates), qs2ba);
2183 
2184  if (!performActualUpdate("MythTV", "DBSchemaVer",
2185  updates, "1306", dbver))
2186  return false;
2187  }
2188 
2189  if (dbver == "1306")
2190  {
2191  // staging temporary tables to use with rewritten file scanner
2192  // due to be replaced by finalized RecordedFile changes
2193 
2194  DBUpdates updates {
2195 "CREATE TABLE scannerfile ("
2196 " `fileid` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,"
2197 " `filesize` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,"
2198 " `filehash` VARCHAR(64) NOT NULL DEFAULT '',"
2199 " `added` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,"
2200 " PRIMARY KEY (`fileid`),"
2201 " UNIQUE KEY filehash (`filehash`)"
2202 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2203 "CREATE TABLE scannerpath ("
2204 " `fileid` BIGINT(20) UNSIGNED NOT NULL,"
2205 " `hostname` VARCHAR(64) NOT NULL DEFAULT 'localhost',"
2206 " `storagegroup` VARCHAR(32) NOT NULL DEFAULT 'Default',"
2207 " `filename` VARCHAR(255) NOT NULL DEFAULT '',"
2208 " PRIMARY KEY (`fileid`)"
2209 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2210 "CREATE TABLE videopart ("
2211 " `fileid` BIGINT(20) UNSIGNED NOT NULL,"
2212 " `videoid` INT(10) UNSIGNED NOT NULL,"
2213 " `order` SMALLINT UNSIGNED NOT NULL DEFAULT 1,"
2214 " PRIMARY KEY `part` (`videoid`, `order`)"
2215 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;"
2216 };
2217 
2218 // removed "UNIQUE KEY path (`storagegroup`, `hostname`, `filename`)" from
2219 // scannerpath as a quick fix for key length constraints
2220 
2221  if (!performActualUpdate("MythTV", "DBSchemaVer",
2222  updates, "1307", dbver))
2223  return false;
2224  }
2225 
2226  if (dbver == "1307")
2227  {
2228  DBUpdates updates {
2229 "ALTER TABLE channel MODIFY COLUMN icon varchar(255) NOT NULL DEFAULT '';",
2230 "UPDATE channel SET icon='' WHERE icon='none';"
2231 };
2232  if (!performActualUpdate("MythTV", "DBSchemaVer",
2233  updates, "1308", dbver))
2234  return false;
2235  }
2236 
2237  if (dbver == "1308")
2238  {
2239  DBUpdates updates {
2240 // Add this time filter
2241 // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
2242 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2243 " VALUES (8, 'This time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2244 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2245 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 1440 <= 10', 0)",
2246 // Add this day and time filter
2247 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2248 " VALUES (9, 'This day and time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2249 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2250 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 10080 <= 10', 0)",
2251 // Convert old, normal Timeslot rules to Channel with time filter
2252 "UPDATE record SET type = 3, filter = filter|256 "
2253 " WHERE type = 2 AND search = 0",
2254 // Convert old, normal Weekslot rules to Channel with day and time filter
2255 "UPDATE record SET type = 3, filter = filter|512 "
2256 " WHERE type = 5 AND search = 0",
2257 // Convert old, normal find daily to new, power search, find daily
2258 "UPDATE record SET type = 2, search = 1, chanid = 0, station = '', "
2259 " subtitle = '', description = CONCAT('program.title = ''', "
2260 " REPLACE(title, '''', ''''''), ''''), "
2261 " title = CONCAT(title, ' (Power Search)') WHERE type = 9 AND search = 0",
2262 // Convert old, normal find weekly to new, power search, find weekly
2263 "UPDATE record SET type = 5, search = 1, chanid = 0, station = '', "
2264 " subtitle = '', description = CONCAT('program.title = ''', "
2265 " REPLACE(title, '''', ''''''), ''''), "
2266 " title = CONCAT(title, ' (Power Search)') WHERE type = 10 AND search = 0",
2267 // Convert old, find daily to new, find daily
2268 "UPDATE record SET type = 2 WHERE type = 9",
2269 // Convert old, find weekly to new, find weekly
2270 "UPDATE record SET type = 5 WHERE type = 10"
2271 };
2272  if (!performActualUpdate("MythTV", "DBSchemaVer",
2273  updates, "1309", dbver))
2274  return false;
2275  }
2276 
2277  if (dbver == "1309")
2278  {
2279  DBUpdates updates {
2280 // Add this channel filter
2281 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2282 " VALUES (10, 'This channel', 'channel.callsign = RECTABLE.station', 0)",
2283 // Convert old, Channel rules to All with channel filter
2284 "UPDATE record SET type = 4, filter = filter|1024 WHERE type = 3"
2285 };
2286  if (!performActualUpdate("MythTV", "DBSchemaVer",
2287  updates, "1310", dbver))
2288  return false;
2289  }
2290 
2291  if (dbver == "1310")
2292  {
2293  DBUpdates updates {
2294 // Move old table temporarily
2295 "RENAME TABLE `housekeeping` TO `oldhousekeeping`;",
2296 // Create new table in its place
2297 "CREATE TABLE `housekeeping` ("
2298 " `tag` VARCHAR(64) NOT NULL,"
2299 " `hostname` VARCHAR(64),"
2300 " `lastrun` DATETIME,"
2301 " UNIQUE KEY `task` (`tag`, `hostname`)"
2302 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2303 // Migrate old data over
2304 "INSERT INTO `housekeeping` (`tag`, `hostname`, `lastrun`)"
2305 " SELECT SUBSTRING_INDEX(`tag`, '-', 1) AS `tag`,"
2306 " IF(LOCATE('-', `tag`) > 0,"
2307 " SUBSTRING(`tag` FROM LENGTH(SUBSTRING_INDEX(`tag`, '-', 1)) +2),"
2308 " NULL) AS `hostname`,"
2309 " `lastrun`"
2310 " FROM `oldhousekeeping`;",
2311 // Delete old data
2312 "DROP TABLE `oldhousekeeping`;"
2313 };
2314 
2315  if (!performActualUpdate("MythTV", "DBSchemaVer",
2316  updates, "1311", dbver))
2317  return false;
2318  }
2319 
2320  if (dbver == "1311")
2321  {
2322  DBUpdates updates {
2323 // Create a global enable/disable instead of one per-host
2324 // Any hosts previously running it mean all hosts do now
2325 "INSERT INTO `settings` (`value`, `hostname`, `data`)"
2326 " SELECT 'HardwareProfileEnabled',"
2327 " NULL,"
2328 " IF((SELECT COUNT(1)"
2329 " FROM `settings`"
2330 " WHERE `value` = 'HardwareProfileLastUpdated' > 0),"
2331 " 1, 0);",
2332 // Create 'lastrun' times using existing data in settings
2333 "INSERT INTO `housekeeping` (`tag`, `hostname`, `lastrun`)"
2334 " SELECT 'HardwareProfiler',"
2335 " `hostname`,"
2336 " `data`"
2337 " FROM `settings`"
2338 " WHERE `value` = 'HardwareProfileLastUpdated';",
2339 // Clear out old settings
2340 "DELETE FROM `settings` WHERE `value` = 'HardwareProfileLastUpdated';"
2341 };
2342  if (!performActualUpdate("MythTV", "DBSchemaVer",
2343  updates, "1312", dbver))
2344  return false;
2345  }
2346 
2347  if (dbver == "1312")
2348  {
2349  DBUpdates updates {
2350 // DVD bookmark updates
2351 "DELETE FROM `dvdbookmark` WHERE `framenum` = 0;",
2352 "ALTER TABLE dvdbookmark ADD COLUMN dvdstate varchar(1024) NOT NULL DEFAULT '';"
2353 };
2354  if (!performActualUpdate("MythTV", "DBSchemaVer",
2355  updates, "1313", dbver))
2356  return false;
2357  }
2358 
2359  if (dbver == "1313")
2360  {
2361  // Make sure channel timeouts are long enough. No actual
2362  // schema change.
2363  DBUpdates updates {
2364  // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
2365  "UPDATE capturecard SET channel_timeout = 3000 WHERE "
2366  "cardtype = \"DVB\" AND channel_timeout < 3000;",
2367  "UPDATE capturecard SET channel_timeout = 30000 WHERE "
2368  "cardtype = \"FREEBOX\" AND channel_timeout < 30000;",
2369  "UPDATE capturecard SET channel_timeout = 9000 WHERE "
2370  "cardtype = \"FIREWIRE\" AND channel_timeout < 9000;",
2371  "UPDATE capturecard SET channel_timeout = 3000 WHERE "
2372  "cardtype = \"HDHOMERUN\" AND channel_timeout < 3000;",
2373  "UPDATE capturecard SET channel_timeout = 15000 WHERE "
2374  "cardtype = \"HDPVR\" AND channel_timeout < 15000;",
2375  "UPDATE capturecard SET channel_timeout = 12000 WHERE "
2376  "cardtype = \"MPEG\" AND channel_timeout < 12000;"
2377  };
2378  if (!performActualUpdate("MythTV", "DBSchemaVer",
2379  updates, "1314", dbver))
2380  return false;
2381  }
2382 
2383  if (dbver == "1314")
2384  {
2385  // Migrate users from tmdb.py to tmdb3.py
2386  // The web interface tmdb.py uses will be shut down 2013-09-15
2387  DBUpdates updates {
2388  "UPDATE settings SET data=REPLACE(data, 'tmdb.py', 'tmdb3.py') "
2389  "WHERE value='MovieGrabber'"
2390  };
2391  if (!performActualUpdate("MythTV", "DBSchemaVer",
2392  updates, "1315", dbver))
2393  return false;
2394  }
2395 
2396  if (dbver == "1315")
2397  {
2398  DBUpdates updates {
2399 "ALTER TABLE program ADD INDEX title_subtitle_start (title, subtitle, starttime);",
2400 "ALTER TABLE program DROP INDEX title;"
2401 };
2402  if (!performActualUpdate("MythTV", "DBSchemaVer",
2403  updates, "1316", dbver))
2404  return false;
2405  }
2406 
2407  if (dbver == "1316")
2408  {
2409  DBUpdates updates {
2410 // adjust programid type in various tables to match the program table
2411 "ALTER TABLE oldrecorded CHANGE COLUMN programid programid varchar(64);",
2412 "ALTER TABLE oldrecorded CHANGE COLUMN seriesid seriesid varchar(64);",
2413 "ALTER TABLE record CHANGE COLUMN programid programid varchar(64);",
2414 "ALTER TABLE record CHANGE COLUMN seriesid seriesid varchar(64);",
2415 "ALTER TABLE recorded CHANGE COLUMN programid programid varchar(64);",
2416 "ALTER TABLE recorded CHANGE COLUMN seriesid seriesid varchar(64);",
2417 "ALTER TABLE recordedprogram CHANGE COLUMN programid programid varchar(64);",
2418 "ALTER TABLE recordedprogram CHANGE COLUMN seriesid seriesid varchar(64);"
2419 };
2420  if (!performActualUpdate("MythTV", "DBSchemaVer",
2421  updates, "1317", dbver))
2422  return false;
2423  }
2424 
2425  if (dbver == "1317")
2426  {
2427  DBUpdates updates {
2428  "CREATE TABLE IF NOT EXISTS gallery_directories ("
2429  " dir_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
2430  " filename VARCHAR(255) NOT NULL,"
2431  " name VARCHAR(255) NOT NULL,"
2432  " path VARCHAR(255) NOT NULL,"
2433  " parent_id INT(11) NOT NULL,"
2434  " dir_count INT(11) NOT NULL DEFAULT '0',"
2435  " file_count INT(11) NOT NULL DEFAULT '0',"
2436  " hidden TINYINT(1) NOT NULL DEFAULT '0'"
2437  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2438  "CREATE TABLE IF NOT EXISTS gallery_files ("
2439  " file_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,"
2440  " filename VARCHAR(255) NOT NULL,"
2441  " name VARCHAR(255) NOT NULL,"
2442  " path VARCHAR(255) NOT NULL,"
2443  " dir_id INT(11) NOT NULL DEFAULT '0',"
2444  " type INT(11) NOT NULL DEFAULT '0',"
2445  " modtime INT(11) NOT NULL DEFAULT '0',"
2446  " size INT(11) NOT NULL DEFAULT '0',"
2447  " extension VARCHAR(255) NOT NULL,"
2448  " angle INT(11) NOT NULL DEFAULT '0',"
2449  " date INT(11) NOT NULL DEFAULT '0',"
2450  " zoom INT(11) NOT NULL DEFAULT '0',"
2451  " hidden TINYINT(1) NOT NULL DEFAULT '0',"
2452  " orientation INT(11) NOT NULL DEFAULT '0'"
2453  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2454  "INSERT INTO settings VALUES ('ImageStorageGroupName', 'Images', NULL);",
2455  "INSERT INTO settings VALUES ('ImageSortOrder', 0, NULL);",
2456  "INSERT INTO settings VALUES ('ImageShowHiddenFiles', 0, NULL);",
2457  "INSERT INTO settings VALUES ('ImageSlideShowTime', 3500, NULL);",
2458  "INSERT INTO settings VALUES ('ImageTransitionType', 1, NULL);",
2459  "INSERT INTO settings VALUES ('ImageTransitionTime', 1000, NULL);"
2460  };
2461 
2462  if (!performActualUpdate("MythTV", "DBSchemaVer",
2463  updates, "1318", dbver))
2464  return false;
2465  }
2466 
2467  if (dbver == "1318")
2468  {
2469  DBUpdates updates {
2470  "ALTER TABLE program "
2471  " ADD COLUMN season INT(4) NOT NULL DEFAULT '0', "
2472  " ADD COLUMN episode INT(4) NOT NULL DEFAULT '0';",
2473  "ALTER TABLE recordedprogram "
2474  " ADD COLUMN season INT(4) NOT NULL DEFAULT '0', "
2475  " ADD COLUMN episode INT(4) NOT NULL DEFAULT '0';"
2476  };
2477 
2478  if (!performActualUpdate("MythTV", "DBSchemaVer",
2479  updates, "1319", dbver))
2480  return false;
2481  }
2482 
2483  if (dbver == "1319")
2484  {
2485  // Total number of episodes in the series (season)
2486  DBUpdates updates {
2487  "ALTER TABLE program "
2488  " ADD COLUMN totalepisodes INT(4) NOT NULL DEFAULT '0';",
2489  "ALTER TABLE recordedprogram "
2490  " ADD COLUMN totalepisodes INT(4) NOT NULL DEFAULT '0';"
2491  };
2492 
2493  if (!performActualUpdate("MythTV", "DBSchemaVer",
2494  updates, "1320", dbver))
2495  return false;
2496  }
2497 
2498  if (dbver == "1320")
2499  {
2500  DBUpdates updates {
2501  "CREATE TABLE IF NOT EXISTS recgroups ("
2502  "recgroupid SMALLINT(4) NOT NULL AUTO_INCREMENT, "
2503  "recgroup VARCHAR(64) NOT NULL DEFAULT '', "
2504  "displayname VARCHAR(64) NOT NULL DEFAULT '', "
2505  "password VARCHAR(40) NOT NULL DEFAULT '', "
2506  "special TINYINT(1) NOT NULL DEFAULT '0',"
2507  "PRIMARY KEY (recgroupid), "
2508  "UNIQUE KEY recgroup ( recgroup )"
2509  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
2510  // Create the built-in, 'special', groups
2511  "INSERT INTO recgroups ( recgroupid, recgroup, special ) VALUES ( 1, 'Default', '1' );",
2512  "INSERT INTO recgroups ( recgroupid, recgroup, special ) VALUES ( 2, 'LiveTV', '1' );",
2513  "INSERT INTO recgroups ( recgroupid, recgroup, special ) VALUES ( 3, 'Deleted', '1' );",
2514  // Copy in the passwords for the built-in groups
2515  "DELETE FROM recgrouppassword WHERE password = '';",
2516  "UPDATE recgroups r, recgrouppassword p SET r.password = p.password WHERE r.recgroup = p.recgroup;",
2517  // Copy over all existing recording groups, this information may be split over three tables!
2518  "INSERT IGNORE INTO recgroups ( recgroup, displayname, password ) SELECT DISTINCT recgroup, recgroup, password FROM recgrouppassword;",
2519  "INSERT IGNORE INTO recgroups ( recgroup, displayname ) SELECT DISTINCT recgroup, recgroup FROM record;",
2520  "INSERT IGNORE INTO recgroups ( recgroup, displayname ) SELECT DISTINCT recgroup, recgroup FROM recorded;",
2521  // Create recgroupid columns in record and recorded tables
2522  "ALTER TABLE record ADD COLUMN recgroupid SMALLINT(4) NOT NULL DEFAULT '1', ADD INDEX ( recgroupid );",
2523  "ALTER TABLE recorded ADD COLUMN recgroupid SMALLINT(4) NOT NULL DEFAULT '1', ADD INDEX ( recgroupid );",
2524  // Populate those columns with the corresponding recgroupid from the new recgroups table
2525  "UPDATE recorded, recgroups SET recorded.recgroupid = recgroups.recgroupid WHERE recorded.recgroup = recgroups.recgroup;",
2526  "UPDATE record, recgroups SET record.recgroupid = recgroups.recgroupid WHERE record.recgroup = recgroups.recgroup;"
2527  };
2528 
2529 
2530 
2531  if (!performActualUpdate("MythTV", "DBSchemaVer",
2532  updates, "1321", dbver))
2533  return false;
2534  }
2535 
2536  if (dbver == "1321")
2537  {
2538  DBUpdates updates {
2539  "ALTER TABLE `housekeeping` ADD COLUMN `lastsuccess` DATETIME;",
2540  "UPDATE `housekeeping` SET `lastsuccess`=`lastrun`;"
2541  };
2542 
2543  if (!performActualUpdate("MythTV", "DBSchemaVer",
2544  updates, "1322", dbver))
2545  return false;
2546  }
2547 
2548  if (dbver == "1322")
2549  {
2550  DBUpdates updates {
2551  // add inetref to (recorded)program before season/episode
2552  // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
2553  "ALTER TABLE program "
2554  " ADD COLUMN inetref varchar(40) DEFAULT '' AFTER videoprop;",
2555  "ALTER TABLE recordedprogram "
2556  " ADD COLUMN inetref varchar(40) DEFAULT '' AFTER videoprop;",
2557  "DELETE FROM settings WHERE value='DefaultStartOffset';",
2558  "DELETE FROM settings WHERE value='DefaultEndOffset';",
2559  "DELETE FROM settings WHERE value='AutoExpireDefault';",
2560  "DELETE FROM settings WHERE value='AutoCommercialFlag';",
2561  "DELETE FROM settings WHERE value='AutoTranscode';",
2562  "DELETE FROM settings WHERE value='DefaultTranscoder';",
2563  "DELETE FROM settings WHERE value='AutoRunUserJob1';",
2564  "DELETE FROM settings WHERE value='AutoRunUserJob2';",
2565  "DELETE FROM settings WHERE value='AutoRunUserJob3';",
2566  "DELETE FROM settings WHERE value='AutoRunUserJob4';",
2567  "DELETE FROM settings WHERE value='AutoMetadataLookup';",
2568  "DELETE FROM housekeeping WHERE tag='DailyCleanup';",
2569  "DELETE FROM housekeeping WHERE tag='ThemeChooserInfoCacheUpdate';"
2570  };
2571  if (!performActualUpdate("MythTV", "DBSchemaVer",
2572  updates, "1323", dbver))
2573  return false;
2574  }
2575 
2576  if (dbver == "1323")
2577  {
2578  DBUpdates updates {
2579  // add columns for Unicable related configuration data, see #9726
2580  "ALTER TABLE diseqc_tree "
2581  " ADD COLUMN scr_userband INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER address, "
2582  " ADD COLUMN scr_frequency INTEGER UNSIGNED NOT NULL DEFAULT 1400 AFTER scr_userband, "
2583  " ADD COLUMN scr_pin INTEGER NOT NULL DEFAULT '-1' AFTER scr_frequency;"
2584  };
2585 
2586  if (!performActualUpdate("MythTV", "DBSchemaVer",
2587  updates, "1324", dbver))
2588  return false;
2589  }
2590 
2591  if (dbver == "1324")
2592  {
2593  DBUpdates updates {
2594  "ALTER TABLE recorded "
2595  " DROP PRIMARY KEY, "
2596  " ADD recordedid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, "
2597  " ADD UNIQUE KEY (chanid, starttime) ;"
2598  };
2599 
2600  if (!performActualUpdate("MythTV", "DBSchemaVer",
2601  updates, "1325", dbver))
2602  return false;
2603  }
2604 
2605  if (dbver == "1325")
2606  {
2607  DBUpdates updates {
2608  "ALTER TABLE recorded ADD inputname VARCHAR(32);"
2609  };
2610 
2611  if (!performActualUpdate("MythTV", "DBSchemaVer",
2612  updates, "1326", dbver))
2613  return false;
2614  }
2615 
2616  if (dbver == "1326")
2617  {
2618  DBUpdates updates {
2619 // Add this time filter
2620 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2621 " VALUES (8, 'This time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2622 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2623 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 1440 "
2624 " NOT BETWEEN 11 AND 1429', 0)",
2625 // Add this day and time filter
2626 "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
2627 " VALUES (9, 'This day and time', 'ABS(TIMESTAMPDIFF(MINUTE, CONVERT_TZ("
2628 " ADDTIME(RECTABLE.startdate, RECTABLE.starttime), ''Etc/UTC'', ''SYSTEM''), "
2629 " CONVERT_TZ(program.starttime, ''Etc/UTC'', ''SYSTEM''))) MOD 10080 "
2630 " NOT BETWEEN 11 AND 10069', 0)"
2631 };
2632  if (!performActualUpdate("MythTV", "DBSchemaVer",
2633  updates, "1327", dbver))
2634  return false;
2635  }
2636 
2637  if (dbver == "1327")
2638  {
2639  DBUpdates updates {
2640  "DELETE r1 FROM record r1, record r2 "
2641  " WHERE r1.chanid = r2.chanid AND "
2642  " r1.starttime = r2.starttime AND "
2643  " r1.startdate = r2.startdate AND "
2644  " r1.title = r2.title AND "
2645  " r1.type = r2.type AND "
2646  " r1.recordid > r2.recordid",
2647  "ALTER TABLE record DROP INDEX chanid",
2648  "ALTER TABLE record ADD UNIQUE INDEX "
2649  " (chanid, starttime, startdate, title, type)"
2650  };
2651  if (!performActualUpdate("MythTV", "DBSchemaVer",
2652  updates, "1328", dbver))
2653  return false;
2654  }
2655 
2656  if (dbver == "1328")
2657  {
2658  DBUpdates updates {
2659  "ALTER TABLE recordedfile "
2660  "DROP KEY `chanid`, "
2661  "DROP COLUMN `chanid`, "
2662  "DROP COLUMN `starttime`;",
2663  "ALTER TABLE recordedfile "
2664  "ADD COLUMN recordedid int(10) unsigned NOT NULL, "
2665  "ADD UNIQUE KEY `recordedid` (recordedid);",
2666  "ALTER TABLE recordedfile "
2667  "CHANGE audio_type audio_codec varchar(255) NOT NULL DEFAULT '';"
2668  "ALTER TABLE recordedfile "
2669  "CHANGE video_type video_codec varchar(255) NOT NULL DEFAULT '';"
2670  };
2671  if (!performActualUpdate("MythTV", "DBSchemaVer",
2672  updates, "1329", dbver))
2673  return false;
2674  }
2675 
2676  if (dbver == "1329")
2677  {
2678  DBUpdates updates {
2679  "ALTER TABLE recordedfile "
2680  "DROP COLUMN audio_bits_per_sample ;", // Instead create two columns for avg and max bitrates
2681  "ALTER TABLE recordedfile "
2682  "ADD COLUMN container VARCHAR(255) NOT NULL DEFAULT '', "
2683  "ADD COLUMN total_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2684  "ADD COLUMN video_avg_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2685  "ADD COLUMN video_max_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2686  "ADD COLUMN audio_avg_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, " // Kbps
2687  "ADD COLUMN audio_max_bitrate MEDIUMINT UNSIGNED NOT NULL DEFAULT 0 ;" // Kbps
2688  };
2689  if (!performActualUpdate("MythTV", "DBSchemaVer",
2690  updates, "1330", dbver))
2691  return false;
2692  }
2693 
2694  if (dbver == "1330")
2695  {
2696  MSqlQuery query(MSqlQuery::InitCon());
2697  query.prepare("SELECT recordedid FROM recorded");
2698  query.exec();
2699  while (query.next())
2700  {
2701  int recordingID = query.value(0).toInt();
2702  auto *recInfo = new RecordingInfo(recordingID);
2703  RecordingFile *recFile = recInfo->GetRecordingFile();
2704  recFile->m_fileName = recInfo->GetBasename();
2705  recFile->m_fileSize = recInfo->GetFilesize();
2706  recFile->m_storageGroup = recInfo->GetStorageGroup();
2707  recFile->m_storageDeviceID = recInfo->GetHostname();
2708  switch (recInfo->QueryAverageAspectRatio())
2709  {
2710  case MARK_ASPECT_1_1 :
2711  recFile->m_videoAspectRatio = 1.0;
2712  break;
2713  case MARK_ASPECT_4_3:
2714  recFile->m_videoAspectRatio = 1.33333333333;
2715  break;
2716  case MARK_ASPECT_16_9:
2717  recFile->m_videoAspectRatio = 1.77777777777;
2718  break;
2719  case MARK_ASPECT_2_21_1:
2720  recFile->m_videoAspectRatio = 2.21;
2721  break;
2722  default:
2723  break;
2724  }
2725  QSize resolution(recInfo->QueryAverageWidth(),
2726  recInfo->QueryAverageHeight());
2727  recFile->m_videoResolution = resolution;
2728  recFile->m_videoFrameRate = (double)recInfo->QueryAverageFrameRate() / 1000.0;
2729  recFile->Save();
2730  delete recInfo;
2731  }
2732 
2733  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1331", dbver))
2734  return false;
2735  }
2736 
2737  if (dbver == "1331")
2738  {
2739  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1332");
2740  MSqlQuery select(MSqlQuery::InitCon());
2741  MSqlQuery update(MSqlQuery::InitCon());
2742 
2743  // Find all second or higher inputs using the same card.
2744  select.prepare("SELECT DISTINCT i1.cardid, i1.cardinputid "
2745  "FROM cardinput i1, cardinput i2 "
2746  "WHERE i1.cardid = i2.cardid AND "
2747  " i1.cardinputid > i2.cardinputid "
2748  "ORDER BY i1.cardid, i1.cardinputid");
2749  if (!select.exec())
2750  {
2751  MythDB::DBError("Unable to retrieve cardinputids.", select);
2752  return false;
2753  }
2754 
2755  while (select.next())
2756  {
2757  int cardid = select.value(0).toInt();
2758  int inputid = select.value(1).toInt();
2759 
2760  // Create a new card for this input.
2761  update.prepare("INSERT INTO capturecard "
2762  " ( videodevice, audiodevice, vbidevice, "
2763  " cardtype, defaultinput, audioratelimit, "
2764  " hostname, dvb_swfilter, dvb_sat_type, "
2765  " dvb_wait_for_seqstart, skipbtaudio, "
2766  " dvb_on_demand, dvb_diseqc_type, "
2767  " firewire_speed, firewire_model, "
2768  " firewire_connection, signal_timeout, "
2769  " channel_timeout, dvb_tuning_delay, "
2770  " contrast, brightness, colour, hue, "
2771  " diseqcid, dvb_eitscan ) "
2772  "SELECT videodevice, audiodevice, vbidevice, "
2773  " cardtype, defaultinput, audioratelimit, "
2774  " hostname, dvb_swfilter, dvb_sat_type, "
2775  " dvb_wait_for_seqstart, skipbtaudio, "
2776  " dvb_on_demand, dvb_diseqc_type, "
2777  " firewire_speed, firewire_model, "
2778  " firewire_connection, signal_timeout, "
2779  " channel_timeout, dvb_tuning_delay, "
2780  " contrast, brightness, colour, hue, "
2781  " diseqcid, dvb_eitscan "
2782  "FROM capturecard c "
2783  "WHERE c.cardid = :CARDID");
2784  update.bindValue(":CARDID", cardid);
2785  if (!update.exec())
2786  {
2787  MythDB::DBError("Unable to insert new card.", update);
2788  return false;
2789  }
2790  int newcardid = update.lastInsertId().toInt();
2791 
2792  // Now attach the input to the new card.
2793  update.prepare("UPDATE cardinput "
2794  "SET cardid = :NEWCARDID "
2795  "WHERE cardinputid = :INPUTID");
2796  update.bindValue(":NEWCARDID", newcardid);
2797  update.bindValue(":INPUTID", inputid);
2798  if (!update.exec())
2799  {
2800  MythDB::DBError("Unable to update input.", update);
2801  return false;
2802  }
2803  }
2804 
2805  DBUpdates updates {
2806  // Delete old, automatically created inputgroups.
2807  "DELETE FROM inputgroup WHERE inputgroupname LIKE 'DVB_%'",
2808  "DELETE FROM inputgroup WHERE inputgroupname LIKE 'CETON_%'",
2809  "DELETE FROM inputgroup WHERE inputgroupname LIKE 'HDHOMERUN_%'",
2810  // Increase the size of inputgroup.inputgroupname.
2811  // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
2812  "ALTER TABLE inputgroup "
2813  " MODIFY COLUMN inputgroupname VARCHAR(48)",
2814  // Rename remaining inputgroups to have 'user:' prefix.
2815  "UPDATE inputgroup "
2816  " SET inputgroupname = CONCAT('user:', inputgroupname)",
2817  // Change inputgroup.inputid to equal cardid.
2818  "UPDATE inputgroup ig "
2819  " JOIN cardinput i ON ig.cardinputid = i.cardinputid "
2820  " SET ig.cardinputid = i.cardid",
2821  // Change record.prefinput to equal cardid.
2822  "UPDATE record r "
2823  " JOIN cardinput i ON r.prefinput = i.cardinputid "
2824  " SET r.prefinput = i.cardid",
2825  // Change diseqc_config.cardinputid to equal cardid.
2826  "UPDATE diseqc_config dc "
2827  " JOIN cardinput i ON dc.cardinputid = i.cardinputid "
2828  " SET dc.cardinputid = i.cardid",
2829  // Change cardinput.cardinputid to equal cardid. Do in
2830  // multiple steps to avoid duplicate ids.
2831  "SELECT MAX(cardid) INTO @maxcardid FROM capturecard",
2832  "SELECT MAX(cardinputid) INTO @maxcardinputid FROM cardinput",
2833  "UPDATE cardinput i "
2834  " SET i.cardinputid = i.cardid + @maxcardid + @maxcardinputid",
2835  "UPDATE cardinput i "
2836  " SET i.cardinputid = i.cardid"
2837  };
2838 
2839  if (!performUpdateSeries("MythTV", updates))
2840  return false;
2841 
2842  // Create an automatically generated inputgroup for each card.
2843  select.prepare("SELECT cardid, hostname, videodevice "
2844  "FROM capturecard c "
2845  "ORDER BY c.cardid");
2846  if (!select.exec())
2847  {
2848  MythDB::DBError("Unable to retrieve cardtids.", select);
2849  return false;
2850  }
2851 
2852  while (select.next())
2853  {
2854  uint cardid = select.value(0).toUInt();
2855  QString host = select.value(1).toString();
2856  QString device = select.value(2).toString();
2857  QString name = host + "|" + device;
2858  uint groupid = CardUtil::CreateInputGroup(name);
2859  if (!groupid)
2860  return false;
2861  if (!CardUtil::LinkInputGroup(cardid, groupid))
2862  return false;
2863  }
2864 
2865  // Remove orphan and administrative inputgroup entries.
2866  if (!CardUtil::UnlinkInputGroup(0, 0))
2867  return false;
2868 
2869  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1332", dbver))
2870  return false;
2871  }
2872 
2873  if (dbver == "1332")
2874  {
2875  DBUpdates updates {
2876  // Move contents of cardinput to capturecard.
2877  "ALTER TABLE capturecard "
2878  " ADD COLUMN inputname VARCHAR(32) NOT NULL DEFAULT '', "
2879  " ADD COLUMN sourceid INT(10) UNSIGNED NOT NULL DEFAULT 0, "
2880  " ADD COLUMN externalcommand VARCHAR(128), "
2881  " ADD COLUMN changer_device VARCHAR(128), "
2882  " ADD COLUMN changer_model VARCHAR(128), "
2883  " ADD COLUMN tunechan VARCHAR(10), "
2884  " ADD COLUMN startchan VARCHAR(10), "
2885  " ADD COLUMN displayname VARCHAR(64) NOT NULL DEFAULT '', "
2886  " ADD COLUMN dishnet_eit TINYINT(1) NOT NULL DEFAULT 0, "
2887  " ADD COLUMN recpriority INT(11) NOT NULL DEFAULT 0, "
2888  " ADD COLUMN quicktune TINYINT(4) NOT NULL DEFAULT 0, "
2889  " ADD COLUMN schedorder INT(10) UNSIGNED NOT NULL DEFAULT 0, "
2890  " ADD COLUMN livetvorder INT(10) UNSIGNED NOT NULL DEFAULT 0",
2891  "UPDATE capturecard c "
2892  " JOIN cardinput i ON c.cardid = i.cardinputid "
2893  " SET c.inputname = i.inputname, "
2894  " c.sourceid = i.sourceid, "
2895  " c.externalcommand = i.externalcommand, "
2896  " c.changer_device = i.changer_device, "
2897  " c.changer_model = i.changer_model, "
2898  " c.tunechan = i.tunechan, "
2899  " c.startchan = i.startchan, "
2900  " c.displayname = i.displayname, "
2901  " c.dishnet_eit = i.dishnet_eit, "
2902  " c.recpriority = i.recpriority, "
2903  " c.quicktune = i.quicktune, "
2904  " c.schedorder = i.schedorder, "
2905  " c.livetvorder = i.livetvorder",
2906  "TRUNCATE cardinput"
2907  };
2908  if (!performActualUpdate("MythTV", "DBSchemaVer",
2909  updates, "1333", dbver))
2910  return false;
2911  }
2912 
2913  if (dbver == "1333")
2914  {
2915  DBUpdates updates {
2916  // Fix default value of capturecard.inputname.
2917  "ALTER TABLE capturecard "
2918  " MODIFY COLUMN inputname VARCHAR(32) NOT NULL DEFAULT 'None'",
2919  "UPDATE capturecard c "
2920  " SET inputname = 'None' WHERE inputname = '' "
2921  };
2922  if (!performActualUpdate("MythTV", "DBSchemaVer",
2923  updates, "1334", dbver))
2924  return false;
2925  }
2926 
2927  if (dbver == "1334")
2928  {
2929  DBUpdates updates {
2930  // Change the default sched/livetvorder from 0 to 1.
2931  "ALTER TABLE capturecard "
2932  " MODIFY COLUMN schedorder INT(10) UNSIGNED "
2933  " NOT NULL DEFAULT 1, "
2934  " MODIFY COLUMN livetvorder INT(10) UNSIGNED "
2935  " NOT NULL DEFAULT 1"
2936  };
2937  if (!performActualUpdate("MythTV", "DBSchemaVer",
2938  updates, "1335", dbver))
2939  return false;
2940  }
2941 
2942  if (dbver == "1335")
2943  {
2944  DBUpdates updates {
2945  // Fix custom record and custom priority references to
2946  // cardinput and cardinputid.
2947  "UPDATE record SET description = "
2948  " replace(description, 'cardinputid', 'cardid') "
2949  " WHERE search = 1",
2950  "UPDATE record SET description = "
2951  " replace(description, 'cardinput', 'capturecard') "
2952  " WHERE search = 1",
2953  "UPDATE powerpriority SET selectclause = "
2954  " replace(selectclause, 'cardinputid', 'cardid')",
2955  "UPDATE powerpriority SET selectclause = "
2956  " replace(selectclause, 'cardinput', 'capturecard')"
2957  };
2958  if (!performActualUpdate("MythTV", "DBSchemaVer",
2959  updates, "1336", dbver))
2960  return false;
2961  }
2962 
2963  if (dbver == "1336")
2964  {
2965  DBUpdates updates {
2966  // Add a parentid columne to capturecard.
2967  "ALTER TABLE capturecard "
2968  " ADD parentid INT UNSIGNED NOT NULL DEFAULT 0 AFTER cardid",
2969  "UPDATE capturecard c, "
2970  " (SELECT min(cardid) cardid, hostname, videodevice, "
2971  " inputname, cardtype "
2972  " FROM capturecard "
2973  " WHERE cardtype NOT IN "
2974  " ('FREEBOX', 'IMPORT', 'DEMO', 'EXTERNAL') "
2975  " GROUP BY hostname, videodevice, inputname) mins "
2976  "SET c.parentid = mins.cardid "
2977  "WHERE c.hostname = mins.hostname and "
2978  " c.videodevice = mins.videodevice and "
2979  " c.inputname = mins.inputname and "
2980  " c.cardid <> mins.cardid"
2981  };
2982  if (!performActualUpdate("MythTV", "DBSchemaVer",
2983  updates, "1337", dbver))
2984  return false;
2985  }
2986 
2987  if (dbver == "1337")
2988  {
2989  DBUpdates updates {
2990  // All next_record, last_record and last_delete to be NULL.
2991  "ALTER TABLE record MODIFY next_record DATETIME NULL",
2992  // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
2993  "UPDATE record SET next_record = NULL "
2994  " WHERE next_record = '0000-00-00 00:00:00'",
2995  "ALTER TABLE record MODIFY last_record DATETIME NULL",
2996  "UPDATE record SET last_record = NULL "
2997  " WHERE last_record = '0000-00-00 00:00:00'",
2998  "ALTER TABLE record MODIFY last_delete DATETIME NULL",
2999  "UPDATE record SET last_delete = NULL "
3000  " WHERE last_delete = '0000-00-00 00:00:00'"
3001  };
3002  if (!performActualUpdate("MythTV", "DBSchemaVer",
3003  updates, "1338", dbver))
3004  return false;
3005  }
3006 
3007  if (dbver == "1338")
3008  {
3009  DBUpdates updates {
3010  "CREATE TABLE users ("
3011  " userid int(5) unsigned NOT NULL AUTO_INCREMENT,"
3012  " username varchar(128) NOT NULL DEFAULT '',"
3013  " password_digest varchar(32) NOT NULL DEFAULT '',"
3014  " lastlogin datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
3015  " PRIMARY KEY (userid),"
3016  " KEY username (username)"
3017  " ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3018  "CREATE TABLE user_permissions ("
3019  " userid int(5) unsigned NOT NULL,"
3020  " permission varchar(128) NOT NULL DEFAULT '',"
3021  " PRIMARY KEY (userid)"
3022  " ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3023  "CREATE TABLE user_sessions ("
3024  " sessiontoken varchar(40) NOT NULL DEFAULT ''," // SHA1
3025  " userid int(5) unsigned NOT NULL,"
3026  " client varchar(128) NOT NULL, "
3027  " created datetime NOT NULL,"
3028  " lastactive datetime NOT NULL,"
3029  " expires datetime NOT NULL,"
3030  " PRIMARY KEY (sessionToken),"
3031  " UNIQUE KEY userid_client (userid,client)"
3032  " ) ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3033  "INSERT INTO users SET username='admin'," // Temporary default account
3034  " password_digest='bcd911b2ecb15ffbd6d8e6e744d60cf6';"
3035  };
3036  if (!performActualUpdate("MythTV", "DBSchemaVer",
3037  updates, "1339", dbver))
3038  return false;
3039  }
3040 
3041  if (dbver == "1339")
3042  {
3043  MSqlQuery query(MSqlQuery::InitCon());
3044 
3045  // insert a new profile group for the VBox
3046  query.prepare("INSERT INTO profilegroups SET name = 'VBox Recorder', "
3047  "cardtype = 'VBOX', is_default = 1;");
3048  if (!query.exec())
3049  {
3050  MythDB::DBError("Unable to insert vbox profilegroup.", query);
3051  return false;
3052  }
3053 
3054  // get the id of the new profile group
3055  int groupid = query.lastInsertId().toInt();
3056 
3057  // insert the recording profiles
3058  query.prepare("INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = :GROUPID;");
3059  query.bindValue(":GROUPID", groupid);
3060  if (!query.exec())
3061  {
3062  MythDB::DBError("Unable to insert 'Default' recordingprofile.", query);
3063  return false;
3064  }
3065 
3066  query.prepare("INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = :GROUPID;");
3067  query.bindValue(":GROUPID", groupid);
3068  if (!query.exec())
3069  {
3070  MythDB::DBError("Unable to insert 'Live TV' recordingprofile.", query);
3071  return false;
3072  }
3073 
3074  query.prepare("INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = :GROUPID;");
3075  query.bindValue(":GROUPID", groupid);
3076  if (!query.exec())
3077  {
3078  MythDB::DBError("Unable to insert 'High Quality' recordingprofile.", query);
3079  return false;
3080  }
3081 
3082  query.prepare("INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = :GROUPID;");
3083  query.bindValue(":GROUPID", groupid);
3084  if (!query.exec())
3085  {
3086  MythDB::DBError("Unable to insert 'Low Quality' recordingprofile.", query);
3087  return false;
3088  }
3089 
3090  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1340", dbver))
3091  return false;
3092  }
3093 
3094  if (dbver == "1340")
3095  {
3096  DBUpdates updates {
3097  // Add filter to ignore episodes (e.g. in a person search)
3098  "REPLACE INTO recordfilter (filterid, description, clause, newruledefault) "
3099  " VALUES (11, 'No episodes', 'program.category_type <> ''series''', 0)"
3100  };
3101  if (!performActualUpdate("MythTV", "DBSchemaVer",
3102  updates, "1341", dbver))
3103  return false;
3104  }
3105 
3106  if (dbver == "1341")
3107  {
3108  DBUpdates updates {
3109  "UPDATE profilegroups SET cardtype='FREEBOX' WHERE cardtype='Freebox'"
3110  };
3111  if (!performActualUpdate("MythTV", "DBSchemaVer",
3112  updates, "1342", dbver))
3113  return false;
3114  }
3115 
3116  if (dbver == "1342")
3117  {
3118  LOG(VB_GENERAL, LOG_CRIT, "Upgrading to MythTV schema version 1343");
3119  MSqlQuery select(MSqlQuery::InitCon());
3120  MSqlQuery update(MSqlQuery::InitCon());
3121 
3122  DBUpdates updates {
3123  // Delete automatically created inputgroups.
3124  "DELETE FROM inputgroup WHERE inputgroupname REGEXP '^[a-z_-]*\\\\|'",
3125  // Increase the size of inputgroup.inputgroupname.
3126  "ALTER TABLE inputgroup "
3127  " MODIFY COLUMN inputgroupname VARCHAR(128)"
3128  };
3129 
3130  if (!performUpdateSeries("MythTV", updates))
3131  return false;
3132 
3133  // Recreate automatically generated inputgroup for each card.
3134  select.prepare("SELECT cardid, parentid, cardtype, hostname, "
3135  " videodevice "
3136  "FROM capturecard c "
3137  "ORDER BY c.cardid");
3138  if (!select.exec())
3139  {
3140  MythDB::DBError("Unable to retrieve cardtids.", select);
3141  return false;
3142  }
3143 
3144  while (select.next())
3145  {
3146  uint cardid = select.value(0).toUInt();
3147  uint parentid = select.value(1).toUInt();
3148  QString type = select.value(2).toString();
3149  QString host = select.value(3).toString();
3150  QString device = select.value(4).toString();
3151  QString name = host + "|" + device;
3152  if (type == "FREEBOX" || type == "IMPORT" ||
3153  type == "DEMO" || type == "EXTERNAL")
3154  name += QString("|%1").arg(parentid ? parentid : cardid);
3155  uint groupid = CardUtil::CreateInputGroup(name);
3156  if (!groupid)
3157  return false;
3158  if (!CardUtil::LinkInputGroup(cardid, groupid))
3159  return false;
3160  }
3161 
3162  // Remove orphan and administrative inputgroup entries.
3163  if (!CardUtil::UnlinkInputGroup(0, 0))
3164  return false;
3165 
3166  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1343", dbver))
3167  return false;
3168  }
3169 
3170  if (dbver == "1343")
3171  {
3172  DBUpdates updates {
3173  "DROP TABLE IF EXISTS bdbookmark;",
3174  "CREATE TABLE bdbookmark ("
3175  " serialid varchar(40) NOT NULL DEFAULT '',"
3176  " `name` varchar(128) DEFAULT NULL,"
3177  " bdstate varchar(4096) NOT NULL DEFAULT '',"
3178  " `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
3179  " PRIMARY KEY (serialid)"
3180  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3181 
3182  // #12612 strip \0 characters from channel/channelscan_channel callsign and name
3183  "UPDATE channel SET callsign=REPLACE(callsign,'\\0',''),"
3184  "name=REPLACE(name,'\\0','');",
3185 
3186  // "BackendWSPort" was removed in caaaeef8166722888012f4ecaf3e9b0f09df512a
3187  "DELETE FROM settings WHERE value='BackendWSPort';"
3188  };
3189 
3190  if (!performActualUpdate("MythTV", "DBSchemaVer",
3191  updates, "1344", dbver))
3192  return false;
3193  }
3194 
3195  if (dbver == "1344")
3196  {
3197  DBUpdates updates {
3198  "ALTER TABLE capturecard ADD COLUMN "
3199  " reclimit INT UNSIGNED DEFAULT 1 NOT NULL",
3200  "UPDATE capturecard cc, "
3201  " ( SELECT IF(parentid>0, parentid, cardid) cardid, "
3202  " count(*) cnt "
3203  " FROM capturecard "
3204  " GROUP BY if(parentid>0, parentid, cardid) "
3205  " ) p "
3206  "SET cc.reclimit = p.cnt "
3207  "WHERE cc.cardid = p.cardid OR cc.parentid = p.cardid"
3208  };
3209 
3210  if (!performActualUpdate("MythTV", "DBSchemaVer",
3211  updates, "1345", dbver))
3212  return false;
3213  }
3214 
3215  if (dbver == "1345")
3216  {
3217  DBUpdates updates {
3218  "ALTER TABLE capturecard ADD COLUMN "
3219  " schedgroup TINYINT(1) DEFAULT 0 NOT NULL"
3220  };
3221 
3222  if (!performActualUpdate("MythTV", "DBSchemaVer",
3223  updates, "1346", dbver))
3224  return false;
3225  }
3226 
3227  /*
3228  * TODO the following settings are no more, clean them up with the next schema change
3229  * to avoid confusion by stale settings in the database
3230  *
3231  * WatchTVGuide
3232  */
3233 
3234  if (dbver == "1346")
3235  {
3236  QString master;
3237  // Create new MasterServerName setting
3238  if (gCoreContext->IsMasterHost())
3239  {
3240  master =
3241  "insert into settings (value,data,hostname) "
3242  "values('MasterServerName','"
3243  + gCoreContext->GetHostName() + "', null);";
3244  }
3245  else
3246  {
3247  master =
3248  "insert into settings (value,data,hostname) "
3249  "select 'MasterServerName', b.hostname, null "
3250  "from settings a, settings b "
3251  "where a.value = 'MasterServerIP' "
3252  "and b.value in ('BackendServerIP','BackendServerIP6')"
3253  "and a.data = b.data;";
3254  }
3255 
3256  DBUpdates updates {
3257  // Create new MasterServerName setting
3258  master.toLocal8Bit().constData(),
3259  // Create new BackendServerAddr setting for each backend server
3260  // Assume using IPV4 value.
3261  "insert into settings (value,data,hostname) "
3262  "select 'BackendServerAddr', data,hostname from settings "
3263  "where value = 'BackendServerIP';",
3264  // Update BackendServerAddr setting for cases where IPV6 is used
3265  "update settings a, settings b "
3266  "set b.data = a.data "
3267  "where a.value = 'BackendServerIP6' "
3268  "and b.hostname = a.hostname "
3269  "and b.value = 'BackendServerAddr' "
3270  "and b.data = '127.0.0.1' "
3271  "and a.data != '::1' "
3272  "and a.data is not null "
3273  "and a.data != ''; ",
3274  // Update BackendServerAddr setting for master backend to
3275  // conform to MasterServerIP setting
3276  "update settings a, settings b, settings c "
3277  "set c.data = a.data "
3278  "where a.value = 'MasterServerIP' " // 1 row
3279  "and b.value = 'MasterServerName' " // 1 row
3280  "and c.value = 'BackendServerAddr' " // 1 row per BE
3281  "and c.hostname = b.data;", // restrict to master
3282  // Delete obsolete settings
3283  "delete from settings "
3284  "where value in ('WatchTVGuide');"
3285  };
3286 
3287  if (!performActualUpdate("MythTV", "DBSchemaVer",
3288  updates, "1347", dbver))
3289  return false;
3290  }
3291 
3292  if (dbver == "1347")
3293  {
3294  DBUpdates updates {
3295  "ALTER TABLE record MODIFY COLUMN startdate DATE DEFAULT NULL",
3296  "ALTER TABLE record MODIFY COLUMN enddate DATE DEFAULT NULL",
3297  "ALTER TABLE record MODIFY COLUMN starttime TIME DEFAULT NULL",
3298  "ALTER TABLE record MODIFY COLUMN endtime TIME DEFAULT NULL"
3299  };
3300  if (!performActualUpdate("MythTV", "DBSchemaVer",
3301  updates, "1348", dbver))
3302  return false;
3303  }
3304 
3305  if (dbver == "1348")
3306  {
3307  DBUpdates updates {
3308  "update capturecard "
3309  " set videodevice=left(videodevice, "
3310  " locate('-', videodevice)-1) "
3311  " where cardtype='HDHOMERUN' "
3312  " and videodevice like '%-%'"
3313  };
3314  if (!performActualUpdate("MythTV", "DBSchemaVer",
3315  updates, "1349", dbver))
3316  return false;
3317  }
3318 
3319  if (dbver == "1349")
3320  {
3321  DBUpdates updates {
3322  // Incorrect DB update removed
3323  };
3324  if (!performActualUpdate("MythTV", "DBSchemaVer",
3325  updates, "1350", dbver))
3326  return false;
3327  }
3328 
3329  if (dbver == "1350")
3330  {
3331  DBUpdates updates {
3332  "ALTER TABLE videosource ADD COLUMN bouquet_id INT DEFAULT 0;",
3333  "ALTER TABLE videosource ADD COLUMN region_id INT DEFAULT 0;"
3334  };
3335  if (!performActualUpdate("MythTV", "DBSchemaVer",
3336  updates, "1351", dbver))
3337  return false;
3338  }
3339 
3340  if (dbver == "1351")
3341  {
3342  DBUpdates updates {
3343  "ALTER TABLE videosource MODIFY bouquet_id INT UNSIGNED;",
3344  "ALTER TABLE videosource MODIFY region_id INT UNSIGNED;",
3345  "ALTER TABLE channel ADD COLUMN service_type INT UNSIGNED DEFAULT 0 AFTER serviceid;"
3346  };
3347  if (!performActualUpdate("MythTV", "DBSchemaVer",
3348  updates, "1352", dbver))
3349  return false;
3350  }
3351 
3352  if (dbver == "1352")
3353  {
3354  DBUpdates updates {
3355  "ALTER TABLE capturecard MODIFY schedgroup TINYINT(1) DEFAULT 1 NOT NULL"
3356  };
3357  if (!performActualUpdate("MythTV", "DBSchemaVer",
3358  updates, "1353", dbver))
3359  return false;
3360  }
3361 
3362  if (dbver == "1353")
3363  {
3364  DBUpdates updates {
3365  "ALTER TABLE channel ADD COLUMN deleted TIMESTAMP NULL"
3366  };
3367  if (!performActualUpdate("MythTV", "DBSchemaVer",
3368  updates, "1354", dbver))
3369  return false;
3370  }
3371 
3372  if (dbver == "1354")
3373  {
3374  DBUpdates updates {
3375  "ALTER TABLE videosource ADD COLUMN scanfrequency INT UNSIGNED DEFAULT 0;"
3376  };
3377  if (!performActualUpdate("MythTV", "DBSchemaVer",
3378  updates, "1355", dbver))
3379  return false;
3380  }
3381 
3382  if (dbver == "1355")
3383  {
3384  DBUpdates updates {
3385  "UPDATE capturecard "
3386  "SET displayname = CONCAT('Input ', cardid) "
3387  "WHERE displayname = ''"
3388  };
3389  if (!performActualUpdate("MythTV", "DBSchemaVer",
3390  updates, "1356", dbver))
3391  return false;
3392  }
3393 
3394  if (dbver == "1356")
3395  {
3396  DBUpdates updates {
3397  "REPLACE INTO recordfilter (filterid, description, clause, "
3398  " newruledefault) "
3399  " VALUES (12, 'Priority channel', 'channel.recpriority > 0', 0)"
3400  };
3401  if (!performActualUpdate("MythTV", "DBSchemaVer",
3402  updates, "1357", dbver))
3403  return false;
3404  }
3405 
3406  if (dbver == "1357")
3407  {
3408  // convert old VideoDisplayProfile settings to new format
3409  MythVideoProfileItem temp;
3410  std::vector<MythVideoProfileItem> profiles;
3411 
3412  MSqlQuery query(MSqlQuery::InitCon());
3413  query.prepare("SELECT profileid, value, data FROM displayprofiles "
3414  "ORDER BY profileid");
3415 
3416  for (;;)
3417  {
3418  if (!query.exec())
3419  break;
3420 
3421  uint currentprofile = 0;
3422  while (query.next())
3423  {
3424  if (query.value(0).toUInt() != currentprofile)
3425  {
3426  if (currentprofile)
3427  {
3428  temp.SetProfileID(currentprofile);
3429  profiles.push_back(temp);
3430  }
3431  temp.Clear();
3432  currentprofile = query.value(0).toUInt();
3433  }
3434  temp.Set(query.value(1).toString(), query.value(2).toString());
3435  }
3436 
3437  if (currentprofile)
3438  {
3439  temp.SetProfileID(currentprofile);
3440  profiles.push_back(temp);
3441  }
3442 
3443  for (const MythVideoProfileItem& profile : qAsConst(profiles))
3444  {
3445  QString newdecoder;
3446  QString newrender;
3447  QString newdeint0;
3448  QString newdeint1;
3449 
3450  QString olddecoder = profile.Get("pref_decoder");
3451  QString oldrender = profile.Get("pref_videorenderer");
3452  QString olddeint0 = profile.Get("pref_deint0");
3453  QString olddeint1 = profile.Get("pref_deint1");
3454 
3455  if (oldrender == "xv-blit")
3456  {
3457  newdecoder = "ffmpeg";
3458  newrender = "opengl-yv12";
3459  }
3460  if (olddecoder == "openmax" || oldrender == "openmax")
3461  {
3462  newdecoder = "mmal-dec";
3463  newrender = "opengl-yv12";
3464  }
3465  if ((olddecoder == "mediacodec") || (olddecoder == "nvdec") ||
3466  (olddecoder == "vda") || (olddecoder == "vaapi2") ||
3467  (olddecoder == "vaapi" && oldrender == "openglvaapi") ||
3468  (olddecoder == "vdpau" && oldrender == "vdpau"))
3469  {
3470  if (oldrender != "opengl-hw")
3471  newrender = "opengl-hw";
3472  }
3473  if (olddecoder == "vda")
3474  newdecoder = "vtb";
3475  if (olddecoder == "vaapi2")
3476  newdecoder = "vaapi";
3477 
3478  auto UpdateDeinterlacer = [](const QString &Olddeint, QString &Newdeint, const QString &Decoder)
3479  {
3480  if (Olddeint.isEmpty())
3481  {
3482  Newdeint = "none";
3483  }
3484  else if (Olddeint == "none" ||
3485  Olddeint.contains(DEINT_QUALITY_SHADER) ||
3486  Olddeint.contains(DEINT_QUALITY_DRIVER) ||
3487  Olddeint.contains(DEINT_QUALITY_LOW) ||
3488  Olddeint.contains(DEINT_QUALITY_MEDIUM) ||
3489  Olddeint.contains(DEINT_QUALITY_HIGH))
3490  {
3491  return;
3492  }
3493 
3494  QStringList newsettings;
3495  bool driver = (Decoder != "ffmpeg") &&
3496  (Olddeint.contains("vaapi") || Olddeint.contains("vdpau") ||
3497  Olddeint.contains("nvdec"));
3498  if (driver)
3499  newsettings << DEINT_QUALITY_DRIVER;
3500  if (Olddeint.contains("opengl") || driver)
3501  newsettings << DEINT_QUALITY_SHADER;
3502 
3503  if (Olddeint.contains("greedy") || Olddeint.contains("yadif") ||
3504  Olddeint.contains("kernel") || Olddeint.contains("advanced") ||
3505  Olddeint.contains("compensated") || Olddeint.contains("adaptive"))
3506  {
3507  newsettings << DEINT_QUALITY_HIGH;
3508  }
3509  else if (Olddeint.contains("bob") || Olddeint.contains("onefield") ||
3510  Olddeint.contains("linedouble"))
3511  {
3512  newsettings << DEINT_QUALITY_LOW;
3513  }
3514  else
3515  {
3516  newsettings << DEINT_QUALITY_MEDIUM;
3517  }
3518  Newdeint = newsettings.join(":");
3519  };
3520 
3521  QString decoder = newdecoder.isEmpty() ? olddecoder : newdecoder;
3522  UpdateDeinterlacer(olddeint0, newdeint0, decoder);
3523  UpdateDeinterlacer(olddeint1, newdeint1, decoder);
3524 
3525  auto UpdateData = [](uint ProfileID, const QString &Value, const QString &Data)
3526  {
3527  MSqlQuery update(MSqlQuery::InitCon());
3528  update.prepare(
3529  "UPDATE displayprofiles SET data = :DATA "
3530  "WHERE profileid = :PROFILEID AND value = :VALUE");
3531  update.bindValue(":PROFILEID", ProfileID);
3532  update.bindValue(":VALUE", Value);
3533  update.bindValue(":DATA", Data);
3534  if (!update.exec())
3535  LOG(VB_GENERAL, LOG_ERR,
3536  QString("Error updating display profile id %1").arg(ProfileID));
3537  };
3538 
3539  uint id = profile.GetProfileID();
3540  if (!newdecoder.isEmpty())
3541  UpdateData(id, "pref_decoder", newdecoder);
3542  if (!newrender.isEmpty())
3543  UpdateData(id, "pref_videorenderer", newrender);
3544  if (!newdeint0.isEmpty())
3545  UpdateData(id, "pref_deint0", newdeint0);
3546  if (!newdeint1.isEmpty())
3547  UpdateData(id, "pref_deint1", newdeint1);
3548  }
3549  break;
3550  }
3551 
3552  // remove old studio levels keybinding
3553  DBUpdates updates {
3554  "DELETE FROM keybindings WHERE action='TOGGLESTUDIOLEVELS'"
3555  };
3556 
3557  if (!performActualUpdate("MythTV", "DBSchemaVer",
3558  updates, "1358", dbver))
3559  return false;
3560  }
3561 
3562  if (dbver == "1358")
3563  {
3564  DBUpdates updates {
3565  // Allow videosouce.userid to be NULL as originally intended.
3566  "ALTER TABLE videosource "
3567  " CHANGE COLUMN userid userid VARCHAR(128) NULL DEFAULT NULL",
3568  // And fix any leftover, empty values.
3569  "UPDATE videosource "
3570  " SET userid = NULL "
3571  " WHERE userid = ''",
3572  // Remove potential clear text credentials no longer usable
3573  "UPDATE videosource "
3574  " SET userid = NULL, password = NULL "
3575  " WHERE xmltvgrabber IN ('schedulesdirect1', 'datadirect')"
3576  };
3577  if (!performActualUpdate("MythTV", "DBSchemaVer",
3578  updates, "1359", dbver))
3579  return false;
3580  }
3581 
3582  if (dbver == "1359")
3583  {
3584  // XineramaMonitorAspectRatio was previously ignored for single screen
3585  // setups but now acts as an override for the display aspect ratio.
3586  // 0.0 indicates 'Auto' - which should be the default.
3587  DBUpdates updates {
3588  "UPDATE settings SET data='0.0' WHERE value='XineramaMonitorAspectRatio'"
3589  };
3590  if (!performActualUpdate("MythTV", "DBSchemaVer",
3591  updates, "1360", dbver))
3592  return false;
3593  }
3594 
3595  if (dbver == "1360")
3596  {
3597  // missed in 1357 - convert old vdpau and openglvaapi renderers to opengl
3598  // convert ancient quartz-blit to opengl as well
3599  MythVideoProfileItem temp;
3600  std::vector<MythVideoProfileItem> profiles;
3601 
3602  MSqlQuery query(MSqlQuery::InitCon());
3603  query.prepare("SELECT profileid, value, data FROM displayprofiles "
3604  "ORDER BY profileid");
3605 
3606  // coverity[unreachable] False positive.
3607  for (;;)
3608  {
3609  if (!query.exec())
3610  break;
3611 
3612  uint currentprofile = 0;
3613  while (query.next())
3614  {
3615  if (query.value(0).toUInt() != currentprofile)
3616  {
3617  if (currentprofile)
3618  {
3619  temp.SetProfileID(currentprofile);
3620  profiles.push_back(temp);
3621  }
3622  temp.Clear();
3623  currentprofile = query.value(0).toUInt();
3624  }
3625  temp.Set(query.value(1).toString(), query.value(2).toString());
3626  }
3627 
3628  if (currentprofile)
3629  {
3630  temp.SetProfileID(currentprofile);
3631  profiles.push_back(temp);
3632  }
3633 
3634  for (const MythVideoProfileItem& profile : qAsConst(profiles))
3635  {
3636  // the old deinterlacers will have been converted already
3637  QString oldrender = profile.Get("pref_videorenderer");
3638  if (oldrender == "quartz-blit" || oldrender == "openglvaapi" ||
3639  oldrender == "vdpau")
3640  {
3641  auto UpdateData = [](uint ProfileID, const QString &Value, const QString &Data)
3642  {
3643  MSqlQuery update(MSqlQuery::InitCon());
3644  update.prepare(
3645  "UPDATE displayprofiles SET data = :DATA "
3646  "WHERE profileid = :PROFILEID AND value = :VALUE");
3647  update.bindValue(":PROFILEID", ProfileID);
3648  update.bindValue(":VALUE", Value);
3649  update.bindValue(":DATA", Data);
3650  if (!update.exec())
3651  LOG(VB_GENERAL, LOG_ERR,
3652  QString("Error updating display profile id %1").arg(ProfileID));
3653  };
3654 
3655  uint id = profile.GetProfileID();
3656  UpdateData(id, "pref_decoder", "ffmpeg");
3657  UpdateData(id, "pref_videorenderer", "opengl-yv12");
3658  }
3659  }
3660  break;
3661  }
3662 
3663  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1361", dbver))
3664  return false;
3665  }
3666  if (dbver == "1361")
3667  {
3668  DBUpdates updates {
3669  "ALTER TABLE program CHANGE COLUMN videoprop videoprop "
3670  " SET('WIDESCREEN', 'HDTV', 'MPEG2', 'AVC', 'HEVC') NOT NULL; ",
3671  "ALTER TABLE recordedprogram CHANGE COLUMN videoprop videoprop "
3672  " SET('WIDESCREEN', 'HDTV', 'MPEG2', 'AVC', 'HEVC', "
3673  " '720', '1080', '4K', '3DTV', 'PROGRESSIVE', "
3674  " 'DAMAGED') NOT NULL; ",
3675  };
3676  if (!performActualUpdate("MythTV", "DBSchemaVer",
3677  updates, "1362", dbver))
3678  return false;
3679  }
3680 
3681  if (dbver == "1362")
3682  {
3683  MSqlQuery select(MSqlQuery::InitCon());
3684  select.prepare(
3685  QString("select index_name from information_schema.statistics "
3686  "where table_schema = '%1' "
3687  "and table_name = 'recordedartwork' "
3688  "and seq_in_index = 1 "
3689  "and column_name = 'inetref'")
3690  .arg(GetMythDB()->GetDatabaseName()));
3691 
3692  if (!select.exec())
3693  {
3694  MythDB::DBError("Unable to retrieve index values.", select);
3695  return false;
3696  }
3697 
3698  DBUpdates updates {
3699  "CREATE INDEX recordedartwork_ix1 ON recordedartwork (inetref); "
3700  };
3701 
3702  // do not create index if already done.
3703  if (select.size() > 0) {
3704  updates.clear();
3705  }
3706 
3707  if (!performActualUpdate("MythTV", "DBSchemaVer",
3708  updates, "1363", dbver))
3709  return false;
3710  }
3711 
3712  if (dbver == "1363")
3713  {
3714  MSqlQuery query(MSqlQuery::InitCon());
3715 
3716  // insert a new profile group for Sat>IP
3717  query.prepare("INSERT INTO profilegroups SET name = 'Sat>IP Recorder', "
3718  "cardtype = 'SATIP', is_default = 1;");
3719  if (!query.exec())
3720  {
3721  MythDB::DBError("Unable to insert Sat>IP profilegroup.", query);
3722  return false;
3723  }
3724 
3725  // get the id of the new profile group
3726  int groupid = query.lastInsertId().toInt();
3727 
3728  // insert the recording profiles
3729  query.prepare("INSERT INTO recordingprofiles SET name = \"Default\", profilegroup = :GROUPID;");
3730  query.bindValue(":GROUPID", groupid);
3731  if (!query.exec())
3732  {
3733  MythDB::DBError("Unable to insert 'Default' recordingprofile.", query);
3734  return false;
3735  }
3736 
3737  query.prepare("INSERT INTO recordingprofiles SET name = \"Live TV\", profilegroup = :GROUPID;");
3738  query.bindValue(":GROUPID", groupid);
3739  if (!query.exec())
3740  {
3741  MythDB::DBError("Unable to insert 'Live TV' recordingprofile.", query);
3742  return false;
3743  }
3744 
3745  query.prepare("INSERT INTO recordingprofiles SET name = \"High Quality\", profilegroup = :GROUPID;");
3746  query.bindValue(":GROUPID", groupid);
3747  if (!query.exec())
3748  {
3749  MythDB::DBError("Unable to insert 'High Quality' recordingprofile.", query);
3750  return false;
3751  }
3752 
3753  query.prepare("INSERT INTO recordingprofiles SET name = \"Low Quality\", profilegroup = :GROUPID;");
3754  query.bindValue(":GROUPID", groupid);
3755  if (!query.exec())
3756  {
3757  MythDB::DBError("Unable to insert 'Low Quality' recordingprofile.", query);
3758  return false;
3759  }
3760 
3761  if (!UpdateDBVersionNumber("MythTV", "DBSchemaVer", "1364", dbver))
3762  return false;
3763  }
3764 
3765  if (dbver == "1364")
3766  {
3767  // Set depmethod to none for all manual, recording rules.
3768  DBUpdates updates {
3769  "UPDATE record SET dupmethod = 1 WHERE search = 5"
3770  };
3771  if (!performActualUpdate("MythTV", "DBSchemaVer",
3772  updates, "1365", dbver))
3773  return false;
3774  }
3775 
3776  if (dbver == "1365")
3777  {
3778  DBUpdates updates {
3779  "ALTER TABLE channelscan_channel ADD COLUMN service_type INT UNSIGNED NOT NULL DEFAULT 0;"
3780  };
3781  if (!performActualUpdate("MythTV", "DBSchemaVer",
3782  updates, "1366", dbver))
3783  return false;
3784  }
3785 
3786  if (dbver == "1366")
3787  {
3788  DBUpdates updates {
3789  "ALTER TABLE channelscan_dtv_multiplex ADD COLUMN signal_strength INT NOT NULL DEFAULT 0;"
3790  };
3791  if (!performActualUpdate("MythTV", "DBSchemaVer",
3792  updates, "1367", dbver))
3793  return false;
3794  }
3795 
3796  if (dbver == "1367")
3797  {
3798  DBUpdates updates {
3799  "ALTER TABLE videosource ADD COLUMN lcnoffset INT UNSIGNED DEFAULT 0;"
3800  };
3801  if (!performActualUpdate("MythTV", "DBSchemaVer",
3802  updates, "1368", dbver))
3803  return false;
3804  }
3805  if (dbver == "1368")
3806  {
3807  DBUpdates updates {
3808  // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
3809  "ALTER TABLE credits ADD COLUMN priority "
3810  " TINYINT UNSIGNED DEFAULT 0;",
3811  "ALTER TABLE credits ADD COLUMN roleid "
3812  " MEDIUMINT UNSIGNED DEFAULT 0;",
3813  "ALTER TABLE credits drop key chanid, "
3814  " add unique key `chanid` "
3815  " (chanid, starttime, person, role, roleid);"
3816  "ALTER TABLE recordedcredits ADD COLUMN priority "
3817  " TINYINT UNSIGNED DEFAULT 0;",
3818  "ALTER TABLE recordedcredits ADD COLUMN roleid "
3819  " MEDIUMINT UNSIGNED DEFAULT 0;",
3820  "ALTER TABLE recordedcredits drop key chanid, "
3821  " add unique key `chanid` "
3822  " (chanid, starttime, person, role, roleid);"
3823  "CREATE TABLE roles (roleid MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,"
3824  " `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin"
3825  " NOT NULL DEFAULT '',"
3826  " PRIMARY KEY (roleid),"
3827  " UNIQUE KEY `name` (`name`)"
3828  ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
3829  };
3830  if (!performActualUpdate("MythTV", "DBSchemaVer",
3831  updates, "1369", dbver))
3832  return false;
3833  }
3834  if (dbver == "1369")
3835  {
3836  DBUpdates updates {
3837  "ALTER TABLE programrating MODIFY COLUMN `system` "
3838  " varchar(128);",
3839  "ALTER TABLE programrating MODIFY COLUMN rating "
3840  " varchar(128);",
3841  "ALTER TABLE recordedrating MODIFY COLUMN `system` "
3842  " varchar(128);",
3843  "ALTER TABLE recordedrating MODIFY COLUMN rating "
3844  " varchar(128);",
3845  };
3846  if (!performActualUpdate("MythTV", "DBSchemaVer",
3847  updates, "1370", dbver))
3848  return false;
3849  }
3850 
3851  if (dbver == "1370")
3852  {
3853  // Migrate users from ttvdb.py to ttvdb4.py
3854  DBUpdates updates {
3855  "UPDATE settings SET data=REPLACE(data, 'ttvdb.py', 'ttvdb4.py') "
3856  "WHERE value='TelevisionGrabber'"
3857  };
3858  if (!performActualUpdate("MythTV", "DBSchemaVer",
3859  updates, "1371", dbver))
3860  return false;
3861  }
3862 
3863  if (dbver == "1371")
3864  {
3865  // Recording extender tables are now created later.
3866 
3867  // If that worked, modify existing tables.
3869  if (!performActualUpdate("MythTV", "DBSchemaVer",
3870  updates, "1372", dbver))
3871  return false;
3872  }
3873 
3874  if (dbver == "1372")
3875  {
3876  DBUpdates updates {
3877  "ALTER TABLE recorded ADD COLUMN lastplay "
3878  " TINYINT UNSIGNED DEFAULT 0 AFTER bookmark;",
3879  };
3880  if (!performActualUpdate("MythTV", "DBSchemaVer",
3881  updates, "1373", dbver))
3882  return false;
3883  }
3884 
3885  if (dbver == "1373")
3886  {
3887  DBUpdates updates {
3888  // adjust inetref prefixes to new grabber script
3889  "UPDATE record SET inetref=REPLACE(inetref, 'ttvdb.py', 'ttvdb4.py');",
3890  "UPDATE recorded SET inetref=REPLACE(inetref, 'ttvdb.py', 'ttvdb4.py');",
3891  "UPDATE oldrecorded SET inetref=REPLACE(inetref, 'ttvdb.py', 'ttvdb4.py');",
3892  "UPDATE videometadata SET inetref=REPLACE(inetref, 'ttvdb.py', 'ttvdb4.py');",
3893  "UPDATE program SET inetref=REPLACE(inetref, 'ttvdb.py', 'ttvdb4.py');",
3894  "UPDATE recordedprogram SET inetref=REPLACE(inetref, 'ttvdb.py', 'ttvdb4.py');",
3895  "UPDATE recordedartwork SET inetref=REPLACE(inetref, 'ttvdb.py', 'ttvdb4.py');"
3896  };
3897  if (!performActualUpdate("MythTV", "DBSchemaVer",
3898  updates, "1374", dbver))
3899  return false;
3900  }
3901 
3902  if (dbver == "1374")
3903  {
3904  // Recording extender tables are now created later.
3905  DBUpdates updates {};
3906  if (!performActualUpdate("MythTV", "DBSchemaVer",
3907  updates, "1375", dbver))
3908  return false;
3909  }
3910 
3911  if (dbver == "1375")
3912  {
3913  // Delete any existing recording extender tables.
3914  DBUpdates updates = getRecordingExtenderDbInfo(-1);
3915  if (!performUpdateSeries("MythTV", updates))
3916  return false;
3917 
3918  // Now (re)create them.
3919  updates = getRecordingExtenderDbInfo(1);
3920  if (!performUpdateSeries("MythTV", updates))
3921  return false;
3922 
3923  // Add new tv listing name ->api name mappings for college
3924  // basketball.
3925  updates = getRecordingExtenderDbInfo(2);
3926  if (!performActualUpdate("MythTV", "DBSchemaVer",
3927  updates, "1376", dbver))
3928  return false;
3929  }
3930 
3931  if (dbver == "1376")
3932  {
3933  DBUpdates updates {
3934  "DROP TABLE IF EXISTS `logging`;",
3935  "UPDATE settings SET data='0' WHERE value='LogEnabled'; ", // Keeps MythWeb happy
3936  };
3937  if (!performActualUpdate("MythTV", "DBSchemaVer",
3938  updates, "1377", dbver))
3939  return false;
3940  }
3941 
3942  if (dbver == "1377")
3943  {
3944  // Change reverted, but the version number can't be reused.
3945  DBUpdates updates {};
3946  if (!performActualUpdate("MythTV", "DBSchemaVer",
3947  updates, "1378", dbver))
3948  return false;
3949  }
3950 
3951  if (dbver == "1378")
3952  {
3953  DBUpdates updates {
3954  "CREATE INDEX dir_id ON gallery_files (dir_id);"
3955  };
3956  if (!performActualUpdate("MythTV", "DBSchemaVer",
3957  updates, "1379", dbver))
3958  return false;
3959  }
3960 
3961  return true;
3962 }
3963 
3983 {
3984  MSqlQuery query(MSqlQuery::InitCon());
3985  query.prepare("SHOW TABLES;");
3986 
3987  // check for > 1 table here since the schemalock table should exist
3988  if (query.exec() && query.isActive() && query.size() > 1)
3989  {
3990  QString msg = QString(
3991  "Told to create a NEW database schema, but the database\n"
3992  "already has %1 tables.\n"
3993  "If you are sure this is a good MythTV database, verify\n"
3994  "that the settings table has the DBSchemaVer variable.\n")
3995  .arg(query.size() - 1);
3996  LOG(VB_GENERAL, LOG_ERR, msg);
3997  return false;
3998  }
3999 
4000  LOG(VB_GENERAL, LOG_NOTICE,
4001  "Inserting MythTV initial database information.");
4002 
4003  DBUpdates updates {
4004 "CREATE TABLE capturecard ("
4005 " cardid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4006 " videodevice varchar(128) DEFAULT NULL,"
4007 " audiodevice varchar(128) DEFAULT NULL,"
4008 " vbidevice varchar(128) DEFAULT NULL,"
4009 " cardtype varchar(32) DEFAULT 'V4L',"
4010 " defaultinput varchar(32) DEFAULT 'Television',"
4011 " audioratelimit int(11) DEFAULT NULL,"
4012 " hostname varchar(64) DEFAULT NULL,"
4013 " dvb_swfilter int(11) DEFAULT '0',"
4014 " dvb_sat_type int(11) NOT NULL DEFAULT '0',"
4015 " dvb_wait_for_seqstart int(11) NOT NULL DEFAULT '1',"
4016 " skipbtaudio tinyint(1) DEFAULT '0',"
4017 " dvb_on_demand tinyint(4) NOT NULL DEFAULT '0',"
4018 " dvb_diseqc_type smallint(6) DEFAULT NULL,"
4019 " firewire_speed int(10) unsigned NOT NULL DEFAULT '0',"
4020 " firewire_model varchar(32) DEFAULT NULL,"
4021 " firewire_connection int(10) unsigned NOT NULL DEFAULT '0',"
4022 " signal_timeout int(11) NOT NULL DEFAULT '1000',"
4023 " channel_timeout int(11) NOT NULL DEFAULT '3000',"
4024 " dvb_tuning_delay int(10) unsigned NOT NULL DEFAULT '0',"
4025 " contrast int(11) NOT NULL DEFAULT '0',"
4026 " brightness int(11) NOT NULL DEFAULT '0',"
4027 " colour int(11) NOT NULL DEFAULT '0',"
4028 " hue int(11) NOT NULL DEFAULT '0',"
4029 " diseqcid int(10) unsigned DEFAULT NULL,"
4030 " dvb_eitscan tinyint(1) NOT NULL DEFAULT '1',"
4031 " PRIMARY KEY (cardid)"
4032 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4033 "CREATE TABLE cardinput ("
4034 " cardinputid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4035 " cardid int(10) unsigned NOT NULL DEFAULT '0',"
4036 " sourceid int(10) unsigned NOT NULL DEFAULT '0',"
4037 " inputname varchar(32) NOT NULL DEFAULT '',"
4038 " externalcommand varchar(128) DEFAULT NULL,"
4039 " changer_device varchar(128) DEFAULT NULL,"
4040 " changer_model varchar(128) DEFAULT NULL,"
4041 " tunechan varchar(10) DEFAULT NULL,"
4042 " startchan varchar(10) DEFAULT NULL,"
4043 " displayname varchar(64) NOT NULL DEFAULT '',"
4044 " dishnet_eit tinyint(1) NOT NULL DEFAULT '0',"
4045 " recpriority int(11) NOT NULL DEFAULT '0',"
4046 " quicktune tinyint(4) NOT NULL DEFAULT '0',"
4047 " schedorder int(10) unsigned NOT NULL DEFAULT '0',"
4048 " livetvorder int(10) unsigned NOT NULL DEFAULT '0',"
4049 " PRIMARY KEY (cardinputid)"
4050 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4051 "CREATE TABLE channel ("
4052 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4053 " channum varchar(10) NOT NULL DEFAULT '',"
4054 " freqid varchar(10) DEFAULT NULL,"
4055 " sourceid int(10) unsigned DEFAULT NULL,"
4056 " callsign varchar(20) NOT NULL DEFAULT '',"
4057 " `name` varchar(64) NOT NULL DEFAULT '',"
4058 " icon varchar(255) NOT NULL DEFAULT '',"
4059 " finetune int(11) DEFAULT NULL,"
4060 " videofilters varchar(255) NOT NULL DEFAULT '',"
4061 " xmltvid varchar(255) NOT NULL DEFAULT '',"
4062 " recpriority int(10) NOT NULL DEFAULT '0',"
4063 " contrast int(11) DEFAULT '32768',"
4064 " brightness int(11) DEFAULT '32768',"
4065 " colour int(11) DEFAULT '32768',"
4066 " hue int(11) DEFAULT '32768',"
4067 " tvformat varchar(10) NOT NULL DEFAULT 'Default',"
4068 " visible tinyint(1) NOT NULL DEFAULT '1',"
4069 " outputfilters varchar(255) NOT NULL DEFAULT '',"
4070 " useonairguide tinyint(1) DEFAULT '0',"
4071 " mplexid smallint(6) DEFAULT NULL,"
4072 " serviceid mediumint(8) unsigned DEFAULT NULL,"
4073 " tmoffset int(11) NOT NULL DEFAULT '0',"
4074 " atsc_major_chan int(10) unsigned NOT NULL DEFAULT '0',"
4075 " atsc_minor_chan int(10) unsigned NOT NULL DEFAULT '0',"
4076 " last_record datetime NOT NULL,"
4077 " default_authority varchar(32) NOT NULL DEFAULT '',"
4078 " commmethod int(11) NOT NULL DEFAULT '-1',"
4079 " iptvid smallint(6) unsigned DEFAULT NULL,"
4080 " PRIMARY KEY (chanid),"
4081 " KEY channel_src (channum,sourceid),"
4082 " KEY sourceid (sourceid,xmltvid,chanid),"
4083 " KEY visible (visible)"
4084 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4085 "CREATE TABLE channelgroup ("
4086 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4087 " chanid int(11) unsigned NOT NULL DEFAULT '0',"
4088 " grpid int(11) NOT NULL DEFAULT '1',"
4089 " PRIMARY KEY (id)"
4090 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4091 "CREATE TABLE channelgroupnames ("
4092 " grpid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4093 " `name` varchar(64) NOT NULL DEFAULT '0',"
4094 " PRIMARY KEY (grpid)"
4095 ") ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;",
4096 "CREATE TABLE channelscan ("
4097 " scanid int(3) unsigned NOT NULL AUTO_INCREMENT,"
4098 " cardid int(3) unsigned NOT NULL,"
4099 " sourceid int(3) unsigned NOT NULL,"
4100 " processed tinyint(1) unsigned NOT NULL,"
4101 " scandate datetime NOT NULL,"
4102 " PRIMARY KEY (scanid)"
4103 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4104 "CREATE TABLE channelscan_channel ("
4105 " transportid int(6) unsigned NOT NULL,"
4106 " scanid int(3) unsigned NOT NULL,"
4107 " mplex_id smallint(6) NOT NULL,"
4108 " source_id int(3) unsigned NOT NULL,"
4109 " channel_id int(3) unsigned NOT NULL DEFAULT '0',"
4110 " callsign varchar(20) NOT NULL DEFAULT '',"
4111 " service_name varchar(64) NOT NULL DEFAULT '',"
4112 " chan_num varchar(10) NOT NULL DEFAULT '',"
4113 " service_id mediumint(8) unsigned NOT NULL DEFAULT '0',"
4114 " atsc_major_channel int(4) unsigned NOT NULL DEFAULT '0',"
4115 " atsc_minor_channel int(4) unsigned NOT NULL DEFAULT '0',"
4116 " use_on_air_guide tinyint(1) NOT NULL DEFAULT '0',"
4117 " hidden tinyint(1) NOT NULL DEFAULT '0',"
4118 " hidden_in_guide tinyint(1) NOT NULL DEFAULT '0',"
4119 " freqid varchar(10) NOT NULL DEFAULT '',"
4120 " icon varchar(255) NOT NULL DEFAULT '',"
4121 " tvformat varchar(10) NOT NULL DEFAULT 'Default',"
4122 " xmltvid varchar(64) NOT NULL DEFAULT '',"
4123 " pat_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4124 " vct_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4125 " vct_chan_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4126 " sdt_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4127 " orig_netid int(5) unsigned NOT NULL DEFAULT '0',"
4128 " netid int(5) unsigned NOT NULL DEFAULT '0',"
4129 " si_standard varchar(10) NOT NULL,"
4130 " in_channels_conf tinyint(1) unsigned NOT NULL DEFAULT '0',"
4131 " in_pat tinyint(1) unsigned NOT NULL DEFAULT '0',"
4132 " in_pmt tinyint(1) unsigned NOT NULL DEFAULT '0',"
4133 " in_vct tinyint(1) unsigned NOT NULL DEFAULT '0',"
4134 " in_nit tinyint(1) unsigned NOT NULL DEFAULT '0',"
4135 " in_sdt tinyint(1) unsigned NOT NULL DEFAULT '0',"
4136 " is_encrypted tinyint(1) unsigned NOT NULL DEFAULT '0',"
4137 " is_data_service tinyint(1) unsigned NOT NULL DEFAULT '0',"
4138 " is_audio_service tinyint(1) unsigned NOT NULL DEFAULT '0',"
4139 " is_opencable tinyint(1) unsigned NOT NULL DEFAULT '0',"
4140 " could_be_opencable tinyint(1) unsigned NOT NULL DEFAULT '0',"
4141 " decryption_status smallint(2) unsigned NOT NULL DEFAULT '0',"
4142 " default_authority varchar(32) NOT NULL DEFAULT ''"
4143 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4144 "CREATE TABLE channelscan_dtv_multiplex ("
4145 " transportid int(6) unsigned NOT NULL AUTO_INCREMENT,"
4146 " scanid int(3) unsigned NOT NULL,"
4147 " mplexid smallint(6) unsigned NOT NULL,"
4148 " frequency bigint(12) unsigned NOT NULL,"
4149 " inversion char(1) NOT NULL DEFAULT 'a',"
4150 " symbolrate bigint(12) unsigned NOT NULL DEFAULT '0',"
4151 " fec varchar(10) NOT NULL DEFAULT 'auto',"
4152 " polarity char(1) NOT NULL DEFAULT '',"
4153 " hp_code_rate varchar(10) NOT NULL DEFAULT 'auto',"
4154 " mod_sys varchar(10) DEFAULT NULL,"
4155 " rolloff varchar(4) DEFAULT NULL,"
4156 " lp_code_rate varchar(10) NOT NULL DEFAULT 'auto',"
4157 " modulation varchar(10) NOT NULL DEFAULT 'auto',"
4158 " transmission_mode char(1) NOT NULL DEFAULT 'a',"
4159 " guard_interval varchar(10) NOT NULL DEFAULT 'auto',"
4160 " hierarchy varchar(10) NOT NULL DEFAULT 'auto',"
4161 " bandwidth char(1) NOT NULL DEFAULT 'a',"
4162 " sistandard varchar(10) NOT NULL,"
4163 " tuner_type smallint(2) unsigned NOT NULL,"
4164 " default_authority varchar(32) NOT NULL DEFAULT '',"
4165 " PRIMARY KEY (transportid)"
4166 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4167 "CREATE TABLE codecparams ("
4168 " `profile` int(10) unsigned NOT NULL DEFAULT '0',"
4169 " `name` varchar(128) NOT NULL DEFAULT '',"
4170 " `value` varchar(128) DEFAULT NULL,"
4171 " PRIMARY KEY (`profile`,`name`)"
4172 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4173 "CREATE TABLE credits ("
4174 " person mediumint(8) unsigned NOT NULL DEFAULT '0',"
4175 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4176 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4177 " role set('actor','director','producer','executive_producer','writer','guest_star','host','adapter','presenter','commentator','guest') NOT NULL DEFAULT '',"
4178 " UNIQUE KEY chanid (chanid,starttime,person,role),"
4179 " KEY person (person,role)"
4180 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4181 "CREATE TABLE customexample ("
4182 " rulename varchar(64) NOT NULL,"
4183 " fromclause varchar(10000) NOT NULL DEFAULT '',"
4184 " whereclause varchar(10000) NOT NULL DEFAULT '',"
4185 " search tinyint(4) NOT NULL DEFAULT '0',"
4186 " PRIMARY KEY (rulename)"
4187 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4188 "CREATE TABLE diseqc_config ("
4189 " cardinputid int(10) unsigned NOT NULL,"
4190 " diseqcid int(10) unsigned NOT NULL,"
4191 " `value` varchar(16) NOT NULL DEFAULT '',"
4192 " KEY id (cardinputid)"
4193 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4194 "CREATE TABLE diseqc_tree ("
4195 " diseqcid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4196 " parentid int(10) unsigned DEFAULT NULL,"
4197 " ordinal tinyint(3) unsigned NOT NULL,"
4198 " `type` varchar(16) NOT NULL DEFAULT '',"
4199 " subtype varchar(16) NOT NULL DEFAULT '',"
4200 " description varchar(32) NOT NULL DEFAULT '',"
4201 " switch_ports tinyint(3) unsigned NOT NULL DEFAULT '0',"
4202 " rotor_hi_speed float NOT NULL DEFAULT '0',"
4203 " rotor_lo_speed float NOT NULL DEFAULT '0',"
4204 " rotor_positions varchar(255) NOT NULL DEFAULT '',"
4205 " lnb_lof_switch int(10) NOT NULL DEFAULT '0',"
4206 " lnb_lof_hi int(10) NOT NULL DEFAULT '0',"
4207 " lnb_lof_lo int(10) NOT NULL DEFAULT '0',"
4208 " cmd_repeat int(11) NOT NULL DEFAULT '1',"
4209 " lnb_pol_inv tinyint(4) NOT NULL DEFAULT '0',"
4210 " address tinyint(3) unsigned NOT NULL DEFAULT '0',"
4211 " PRIMARY KEY (diseqcid),"
4212 " KEY parentid (parentid)"
4213 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4214 "CREATE TABLE displayprofilegroups ("
4215 " `name` varchar(128) NOT NULL,"
4216 " hostname varchar(64) NOT NULL,"
4217 " profilegroupid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4218 " PRIMARY KEY (`name`,hostname),"
4219 " UNIQUE KEY profilegroupid (profilegroupid)"
4220 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4221 "CREATE TABLE displayprofiles ("
4222 " profilegroupid int(10) unsigned NOT NULL,"
4223 " profileid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4224 " `value` varchar(128) NOT NULL,"
4225 " `data` varchar(255) NOT NULL DEFAULT '',"
4226 " KEY profilegroupid (profilegroupid),"
4227 " KEY profileid (profileid,`value`),"
4228 " KEY profileid_2 (profileid)"
4229 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4230 "CREATE TABLE dtv_multiplex ("
4231 " mplexid smallint(6) NOT NULL AUTO_INCREMENT,"
4232 " sourceid smallint(6) DEFAULT NULL,"
4233 " transportid int(11) DEFAULT NULL,"
4234 " networkid int(11) DEFAULT NULL,"
4235 " frequency int(11) DEFAULT NULL,"
4236 " inversion char(1) DEFAULT 'a',"
4237 " symbolrate int(11) DEFAULT NULL,"
4238 " fec varchar(10) DEFAULT 'auto',"
4239 " polarity char(1) DEFAULT NULL,"
4240 " modulation varchar(10) DEFAULT 'auto',"
4241 " bandwidth char(1) DEFAULT 'a',"
4242 " lp_code_rate varchar(10) DEFAULT 'auto',"
4243 " transmission_mode char(1) DEFAULT 'a',"
4244 " guard_interval varchar(10) DEFAULT 'auto',"
4245 " visible smallint(1) NOT NULL DEFAULT '0',"
4246 " constellation varchar(10) DEFAULT 'auto',"
4247 " hierarchy varchar(10) DEFAULT 'auto',"
4248 " hp_code_rate varchar(10) DEFAULT 'auto',"
4249 " mod_sys varchar(10) DEFAULT NULL,"
4250 " rolloff varchar(4) DEFAULT NULL,"
4251 " sistandard varchar(10) DEFAULT 'dvb',"
4252 " serviceversion smallint(6) DEFAULT '33',"
4253 " updatetimestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4254 " default_authority varchar(32) NOT NULL DEFAULT '',"
4255 " PRIMARY KEY (mplexid)"
4256 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4257 "CREATE TABLE dtv_privatetypes ("
4258 " sitype varchar(4) NOT NULL DEFAULT '',"
4259 " networkid int(11) NOT NULL DEFAULT '0',"
4260 " private_type varchar(20) NOT NULL DEFAULT '',"
4261 " private_value varchar(100) NOT NULL DEFAULT ''"
4262 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4263 "CREATE TABLE dvdbookmark ("
4264 " serialid varchar(16) NOT NULL DEFAULT '',"
4265 " `name` varchar(32) DEFAULT NULL,"
4266 " title smallint(6) NOT NULL DEFAULT '0',"
4267 " audionum tinyint(4) NOT NULL DEFAULT '-1',"
4268 " subtitlenum tinyint(4) NOT NULL DEFAULT '-1',"
4269 " framenum bigint(20) NOT NULL DEFAULT '0',"
4270 " `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4271 " PRIMARY KEY (serialid)"
4272 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4273 "CREATE TABLE dvdinput ("
4274 " intid int(10) unsigned NOT NULL,"
4275 " hsize int(10) unsigned DEFAULT NULL,"
4276 " vsize int(10) unsigned DEFAULT NULL,"
4277 " ar_num int(10) unsigned DEFAULT NULL,"
4278 " ar_denom int(10) unsigned DEFAULT NULL,"
4279 " fr_code int(10) unsigned DEFAULT NULL,"
4280 " letterbox tinyint(1) DEFAULT NULL,"
4281 " v_format varchar(16) DEFAULT NULL,"
4282 " PRIMARY KEY (intid)"
4283 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4284 "CREATE TABLE dvdtranscode ("
4285 " intid int(11) NOT NULL AUTO_INCREMENT,"
4286 " input int(10) unsigned DEFAULT NULL,"
4287 " `name` varchar(128) NOT NULL,"
4288 " sync_mode int(10) unsigned DEFAULT NULL,"
4289 " use_yv12 tinyint(1) DEFAULT NULL,"
4290 " cliptop int(11) DEFAULT NULL,"
4291 " clipbottom int(11) DEFAULT NULL,"
4292 " clipleft int(11) DEFAULT NULL,"
4293 " clipright int(11) DEFAULT NULL,"
4294 " f_resize_h int(11) DEFAULT NULL,"
4295 " f_resize_w int(11) DEFAULT NULL,"
4296 " hq_resize_h int(11) DEFAULT NULL,"
4297 " hq_resize_w int(11) DEFAULT NULL,"
4298 " grow_h int(11) DEFAULT NULL,"
4299 " grow_w int(11) DEFAULT NULL,"
4300 " clip2top int(11) DEFAULT NULL,"
4301 " clip2bottom int(11) DEFAULT NULL,"
4302 " clip2left int(11) DEFAULT NULL,"
4303 " clip2right int(11) DEFAULT NULL,"
4304 " codec varchar(128) NOT NULL,"
4305 " codec_param varchar(128) DEFAULT NULL,"
4306 " bitrate int(11) DEFAULT NULL,"
4307 " a_sample_r int(11) DEFAULT NULL,"
4308 " a_bitrate int(11) DEFAULT NULL,"
4309 " two_pass tinyint(1) DEFAULT NULL,"
4310 " tc_param varchar(128) DEFAULT NULL,"
4311 " PRIMARY KEY (intid)"
4312 ") ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;",
4313 "CREATE TABLE eit_cache ("
4314 " chanid int(10) NOT NULL,"
4315 " eventid int(10) unsigned NOT NULL DEFAULT '0',"
4316 " tableid tinyint(3) unsigned NOT NULL,"
4317 " version tinyint(3) unsigned NOT NULL,"
4318 " endtime int(10) unsigned NOT NULL,"
4319 " `status` tinyint(4) NOT NULL DEFAULT '0',"
4320 " PRIMARY KEY (chanid,eventid,`status`)"
4321 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4322 "CREATE TABLE filemarkup ("
4323 " filename text NOT NULL,"
4324 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4325 " `offset` bigint(20) unsigned DEFAULT NULL,"
4326 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4327 " KEY filename (filename(255))"
4328 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4329 "CREATE TABLE housekeeping ("
4330 " tag varchar(64) NOT NULL DEFAULT '',"
4331 " lastrun datetime DEFAULT NULL,"
4332 " PRIMARY KEY (tag)"
4333 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4334 "CREATE TABLE inputgroup ("
4335 " cardinputid int(10) unsigned NOT NULL,"
4336 " inputgroupid int(10) unsigned NOT NULL,"
4337 " inputgroupname varchar(32) NOT NULL"
4338 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4339 "CREATE TABLE internetcontent ("
4340 " `name` varchar(255) NOT NULL,"
4341 " thumbnail varchar(255) DEFAULT NULL,"
4342 " `type` smallint(3) NOT NULL,"
4343 " author varchar(128) NOT NULL,"
4344 " description text NOT NULL,"
4345 " commandline text NOT NULL,"
4346 " version double NOT NULL,"
4347 " updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4348 " search tinyint(1) NOT NULL,"
4349 " tree tinyint(1) NOT NULL,"
4350 " podcast tinyint(1) NOT NULL,"
4351 " download tinyint(1) NOT NULL,"
4352 " `host` varchar(128) DEFAULT NULL"
4353 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4354 "CREATE TABLE internetcontentarticles ("
4355 " feedtitle varchar(255) NOT NULL,"
4356 " path text NOT NULL,"
4357 " paththumb text NOT NULL,"
4358 " title varchar(255) NOT NULL,"
4359 " subtitle varchar(255) NOT NULL,"
4360 " season smallint(5) NOT NULL DEFAULT '0',"
4361 " episode smallint(5) NOT NULL DEFAULT '0',"
4362 " description text NOT NULL,"
4363 " url text NOT NULL,"
4364 " `type` smallint(3) NOT NULL,"
4365 " thumbnail text NOT NULL,"
4366 " mediaURL text NOT NULL,"
4367 " author varchar(255) NOT NULL,"
4368 " `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4369 " `time` int(11) NOT NULL,"
4370 " rating varchar(255) NOT NULL,"
4371 " filesize bigint(20) NOT NULL,"
4372 " player varchar(255) NOT NULL,"
4373 " playerargs text NOT NULL,"
4374 " download varchar(255) NOT NULL,"
4375 " downloadargs text NOT NULL,"
4376 " width smallint(6) NOT NULL,"
4377 " height smallint(6) NOT NULL,"
4378 " `language` varchar(128) NOT NULL,"
4379 " podcast tinyint(1) NOT NULL,"
4380 " downloadable tinyint(1) NOT NULL,"
4381 " customhtml tinyint(1) NOT NULL,"
4382 " countries varchar(255) NOT NULL"
4383 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4384 "CREATE TABLE inuseprograms ("
4385 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4386 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4387 " recusage varchar(128) NOT NULL DEFAULT '',"
4388 " lastupdatetime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4389 " hostname varchar(64) NOT NULL DEFAULT '',"
4390 " rechost varchar(64) NOT NULL,"
4391 " recdir varchar(255) NOT NULL DEFAULT '',"
4392 " KEY chanid (chanid,starttime),"
4393 " KEY recusage (recusage,lastupdatetime)"
4394 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4395 "CREATE TABLE iptv_channel ("
4396 " iptvid smallint(6) unsigned NOT NULL AUTO_INCREMENT,"
4397 " chanid int(10) unsigned NOT NULL,"
4398 " url text NOT NULL,"
4399 " `type` set('data','rfc2733-1','rfc2733-2','rfc5109-1','rfc5109-2','smpte2022-1','smpte2022-2') DEFAULT NULL,"
4400 " bitrate int(10) unsigned NOT NULL,"
4401 " PRIMARY KEY (iptvid)"
4402 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4403 "CREATE TABLE jobqueue ("
4404 " id int(11) NOT NULL AUTO_INCREMENT,"
4405 " chanid int(10) NOT NULL DEFAULT '0',"
4406 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4407 " inserttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4408 " `type` int(11) NOT NULL DEFAULT '0',"
4409 " cmds int(11) NOT NULL DEFAULT '0',"
4410 " flags int(11) NOT NULL DEFAULT '0',"
4411 " `status` int(11) NOT NULL DEFAULT '0',"
4412 " statustime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4413 " hostname varchar(64) NOT NULL DEFAULT '',"
4414 " args blob NOT NULL,"
4415 " `comment` varchar(128) NOT NULL DEFAULT '',"
4416 " schedruntime datetime NOT NULL DEFAULT '2007-01-01 00:00:00',"
4417 " PRIMARY KEY (id),"
4418 " UNIQUE KEY chanid (chanid,starttime,`type`,inserttime)"
4419 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4420 "CREATE TABLE jumppoints ("
4421 " destination varchar(128) NOT NULL DEFAULT '',"
4422 " description varchar(255) DEFAULT NULL,"
4423 " keylist varchar(128) DEFAULT NULL,"
4424 " hostname varchar(64) NOT NULL DEFAULT '',"
4425 " PRIMARY KEY (destination,hostname)"
4426 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4427 "CREATE TABLE keybindings ("
4428 " `context` varchar(32) NOT NULL DEFAULT '',"
4429 " `action` varchar(32) NOT NULL DEFAULT '',"
4430 " description varchar(255) DEFAULT NULL,"
4431 " keylist varchar(128) DEFAULT NULL,"
4432 " hostname varchar(64) NOT NULL DEFAULT '',"
4433 " PRIMARY KEY (`context`,`action`,hostname)"
4434 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4435 "CREATE TABLE keyword ("
4436 " phrase varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4437 " searchtype int(10) unsigned NOT NULL DEFAULT '3',"
4438 " UNIQUE KEY phrase (phrase,searchtype)"
4439 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4440 "CREATE TABLE livestream ("
4441 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4442 " width int(10) unsigned NOT NULL,"
4443 " height int(10) unsigned NOT NULL,"
4444 " bitrate int(10) unsigned NOT NULL,"
4445 " audiobitrate int(10) unsigned NOT NULL,"
4446 " samplerate int(10) unsigned NOT NULL,"
4447 " audioonlybitrate int(10) unsigned NOT NULL,"
4448 " segmentsize int(10) unsigned NOT NULL DEFAULT '10',"
4449 " maxsegments int(10) unsigned NOT NULL DEFAULT '0',"
4450 " startsegment int(10) unsigned NOT NULL DEFAULT '0',"
4451 " currentsegment int(10) unsigned NOT NULL DEFAULT '0',"
4452 " segmentcount int(10) unsigned NOT NULL DEFAULT '0',"
4453 " percentcomplete int(10) unsigned NOT NULL DEFAULT '0',"
4454 " created datetime NOT NULL,"
4455 " lastmodified datetime NOT NULL,"
4456 " relativeurl varchar(512) NOT NULL,"
4457 " fullurl varchar(1024) NOT NULL,"
4458 " `status` int(10) unsigned NOT NULL DEFAULT '0',"
4459 " statusmessage varchar(256) NOT NULL,"
4460 " sourcefile varchar(512) NOT NULL,"
4461 " sourcehost varchar(64) NOT NULL,"
4462 " sourcewidth int(10) unsigned NOT NULL DEFAULT '0',"
4463 " sourceheight int(10) unsigned NOT NULL DEFAULT '0',"
4464 " outdir varchar(256) NOT NULL,"
4465 " outbase varchar(128) NOT NULL,"
4466 " PRIMARY KEY (id)"
4467 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4468 "CREATE TABLE logging ("
4469 " id bigint(20) unsigned NOT NULL AUTO_INCREMENT,"
4470 " `host` varchar(64) NOT NULL DEFAULT '',"
4471 " application varchar(64) NOT NULL DEFAULT '',"
4472 " pid int(11) NOT NULL DEFAULT '0',"
4473 " tid int(11) NOT NULL DEFAULT '0',"
4474 " thread varchar(64) NOT NULL DEFAULT '',"
4475 " filename varchar(255) NOT NULL DEFAULT '',"
4476 " line int(11) NOT NULL DEFAULT '0',"
4477 " `function` varchar(255) NOT NULL DEFAULT '',"
4478 " msgtime datetime NOT NULL,"
4479 " `level` int(11) NOT NULL DEFAULT '0',"
4480 " message varchar(2048) NOT NULL,"
4481 " PRIMARY KEY (id),"
4482 " KEY `host` (`host`,application,pid,msgtime),"
4483 " KEY msgtime (msgtime),"
4484 " KEY `level` (`level`)"
4485 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4486 "CREATE TABLE mythlog ("
4487 " logid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4488 " module varchar(32) NOT NULL DEFAULT '',"
4489 " priority int(11) NOT NULL DEFAULT '0',"
4490 " acknowledged tinyint(1) DEFAULT '0',"
4491 " logdate datetime DEFAULT NULL,"
4492 " `host` varchar(128) DEFAULT NULL,"
4493 " message varchar(255) NOT NULL DEFAULT '',"
4494 " details varchar(16000) NOT NULL DEFAULT '',"
4495 " PRIMARY KEY (logid),"
4496 " KEY module (module)"
4497 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4498 "CREATE TABLE oldfind ("
4499 " recordid int(11) NOT NULL DEFAULT '0',"
4500 " findid int(11) NOT NULL DEFAULT '0',"
4501 " PRIMARY KEY (recordid,findid)"
4502 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4503 "CREATE TABLE oldprogram ("
4504 " oldtitle varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4505 " airdate datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4506 " PRIMARY KEY (oldtitle)"
4507 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4508 "CREATE TABLE oldrecorded ("
4509 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4510 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4511 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4512 " title varchar(128) NOT NULL DEFAULT '',"
4513 " subtitle varchar(128) NOT NULL DEFAULT '',"
4514 " description varchar(16000) NOT NULL DEFAULT '',"
4515 " season smallint(5) NOT NULL,"
4516 " episode smallint(5) NOT NULL,"
4517 " category varchar(64) NOT NULL DEFAULT '',"
4518 " seriesid varchar(40) NOT NULL DEFAULT '',"
4519 " programid varchar(40) NOT NULL DEFAULT '',"
4520 " inetref varchar(40) NOT NULL,"
4521 " findid int(11) NOT NULL DEFAULT '0',"
4522 " recordid int(11) NOT NULL DEFAULT '0',"
4523 " station varchar(20) NOT NULL DEFAULT '',"
4524 " rectype int(10) unsigned NOT NULL DEFAULT '0',"
4525 " `duplicate` tinyint(1) NOT NULL DEFAULT '0',"
4526 " recstatus int(11) NOT NULL DEFAULT '0',"
4527 " reactivate smallint(6) NOT NULL DEFAULT '0',"
4528 " generic tinyint(1) NOT NULL,"
4529 " future tinyint(1) NOT NULL DEFAULT '0',"
4530 " PRIMARY KEY (station,starttime,title),"
4531 " KEY endtime (endtime),"
4532 " KEY title (title),"
4533 " KEY seriesid (seriesid),"
4534 " KEY programid (programid),"
4535 " KEY recordid (recordid),"
4536 " KEY recstatus (recstatus,programid,seriesid),"
4537 " KEY recstatus_2 (recstatus,title,subtitle),"
4538 " KEY future (future),"
4539 " KEY chanid (chanid,starttime),"
4540 " KEY subtitle (subtitle),"
4541 " KEY description (description(255))"
4542 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4543 "CREATE TABLE people ("
4544 " person mediumint(8) unsigned NOT NULL AUTO_INCREMENT,"
4545 " `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4546 " PRIMARY KEY (person),"
4547 " UNIQUE KEY `name` (`name`(41))"
4548 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4549 "CREATE TABLE pidcache ("
4550 " chanid smallint(6) NOT NULL DEFAULT '0',"
4551 " pid int(11) NOT NULL DEFAULT '-1',"
4552 " tableid int(11) NOT NULL DEFAULT '-1',"
4553 " KEY chanid (chanid)"
4554 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4555 "CREATE TABLE playgroup ("
4556 " `name` varchar(32) NOT NULL DEFAULT '',"
4557 " titlematch varchar(255) NOT NULL DEFAULT '',"
4558 " skipahead int(11) NOT NULL DEFAULT '0',"
4559 " skipback int(11) NOT NULL DEFAULT '0',"
4560 " timestretch int(11) NOT NULL DEFAULT '0',"
4561 " jump int(11) NOT NULL DEFAULT '0',"
4562 " PRIMARY KEY (`name`)"
4563 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4564 "CREATE TABLE powerpriority ("
4565 " priorityname varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,"
4566 " recpriority int(10) NOT NULL DEFAULT '0',"
4567 " selectclause varchar(16000) NOT NULL DEFAULT '',"
4568 " PRIMARY KEY (priorityname)"
4569 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4570 "CREATE TABLE profilegroups ("
4571 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4572 " `name` varchar(128) DEFAULT NULL,"
4573 " cardtype varchar(32) NOT NULL DEFAULT 'V4L',"
4574 " is_default int(1) DEFAULT '0',"
4575 " hostname varchar(64) DEFAULT NULL,"
4576 " PRIMARY KEY (id),"
4577 " UNIQUE KEY `name` (`name`,hostname),"
4578 " KEY cardtype (cardtype)"
4579 ") ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;",
4580 "CREATE TABLE program ("
4581 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4582 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4583 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4584 " title varchar(128) NOT NULL DEFAULT '',"
4585 " subtitle varchar(128) NOT NULL DEFAULT '',"
4586 " description varchar(16000) NOT NULL DEFAULT '',"
4587 " category varchar(64) NOT NULL DEFAULT '',"
4588 " category_type varchar(64) NOT NULL DEFAULT '',"
4589 " airdate year(4) NOT NULL DEFAULT '0000',"
4590 " stars float NOT NULL DEFAULT '0',"
4591 " previouslyshown tinyint(4) NOT NULL DEFAULT '0',"
4592 " title_pronounce varchar(128) NOT NULL DEFAULT '',"
4593 " stereo tinyint(1) NOT NULL DEFAULT '0',"
4594 " subtitled tinyint(1) NOT NULL DEFAULT '0',"
4595 " hdtv tinyint(1) NOT NULL DEFAULT '0',"
4596 " closecaptioned tinyint(1) NOT NULL DEFAULT '0',"
4597 " partnumber int(11) NOT NULL DEFAULT '0',"
4598 " parttotal int(11) NOT NULL DEFAULT '0',"
4599 " seriesid varchar(64) NOT NULL DEFAULT '',"
4600 " originalairdate date DEFAULT NULL,"
4601 " showtype varchar(30) NOT NULL DEFAULT '',"
4602 " colorcode varchar(20) NOT NULL DEFAULT '',"
4603 " syndicatedepisodenumber varchar(20) NOT NULL DEFAULT '',"
4604 " programid varchar(64) NOT NULL DEFAULT '',"
4605 " manualid int(10) unsigned NOT NULL DEFAULT '0',"
4606 " generic tinyint(1) DEFAULT '0',"
4607 " listingsource int(11) NOT NULL DEFAULT '0',"
4608 " `first` tinyint(1) NOT NULL DEFAULT '0',"
4609 " `last` tinyint(1) NOT NULL DEFAULT '0',"
4610 " audioprop set('STEREO','MONO','SURROUND','DOLBY','HARDHEAR','VISUALIMPAIR') NOT NULL,"
4611 " subtitletypes set('HARDHEAR','NORMAL','ONSCREEN','SIGNED') NOT NULL,"
4612 " videoprop set('HDTV','WIDESCREEN','AVC') NOT NULL,"
4613 " PRIMARY KEY (chanid,starttime,manualid),"
4614 " KEY endtime (endtime),"
4615 " KEY title (title),"
4616 " KEY title_pronounce (title_pronounce),"
4617 " KEY seriesid (seriesid),"
4618 " KEY id_start_end (chanid,starttime,endtime),"
4619 " KEY program_manualid (manualid),"
4620 " KEY previouslyshown (previouslyshown),"
4621 " KEY programid (programid,starttime),"
4622 " KEY starttime (starttime),"
4623 " KEY subtitle (subtitle),"
4624 " KEY description (description(255))"
4625 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4626 "CREATE TABLE programgenres ("
4627 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4628 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4629 " relevance char(1) NOT NULL DEFAULT '',"
4630 " genre varchar(30) DEFAULT NULL,"
4631 " PRIMARY KEY (chanid,starttime,relevance),"
4632 " KEY genre (genre)"
4633 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4634 "CREATE TABLE programrating ("
4635 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4636 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4637 " `system` varchar(8) DEFAULT NULL,"
4638 " rating varchar(16) DEFAULT NULL,"
4639 " UNIQUE KEY chanid (chanid,starttime,`system`,rating),"
4640 " KEY starttime (starttime,`system`)"
4641 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4642 "CREATE TABLE recgrouppassword ("
4643 " recgroup varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4644 " `password` varchar(10) NOT NULL DEFAULT '',"
4645 " PRIMARY KEY (recgroup)"
4646 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4647 "CREATE TABLE record ("
4648 " recordid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4649 " `type` int(10) unsigned NOT NULL DEFAULT '0',"
4650 " chanid int(10) unsigned DEFAULT NULL,"
4651 " starttime time NOT NULL DEFAULT '00:00:00',"
4652 " startdate date NOT NULL DEFAULT '0000-00-00',"
4653 " endtime time NOT NULL DEFAULT '00:00:00',"
4654 " enddate date NOT NULL DEFAULT '0000-00-00',"
4655 " title varchar(128) NOT NULL DEFAULT '',"
4656 " subtitle varchar(128) NOT NULL DEFAULT '',"
4657 " description varchar(16000) NOT NULL DEFAULT '',"
4658 " season smallint(5) NOT NULL,"
4659 " episode smallint(5) NOT NULL,"
4660 " category varchar(64) NOT NULL DEFAULT '',"
4661 " `profile` varchar(128) NOT NULL DEFAULT 'Default',"
4662 " recpriority int(10) NOT NULL DEFAULT '0',"
4663 " autoexpire int(11) NOT NULL DEFAULT '0',"
4664 " maxepisodes int(11) NOT NULL DEFAULT '0',"
4665 " maxnewest int(11) NOT NULL DEFAULT '0',"
4666 " startoffset int(11) NOT NULL DEFAULT '0',"
4667 " endoffset int(11) NOT NULL DEFAULT '0',"
4668 " recgroup varchar(32) NOT NULL DEFAULT 'Default',"
4669 " dupmethod int(11) NOT NULL DEFAULT '6',"
4670 " dupin int(11) NOT NULL DEFAULT '15',"
4671 " station varchar(20) NOT NULL DEFAULT '',"
4672 " seriesid varchar(40) NOT NULL DEFAULT '',"
4673 " programid varchar(40) NOT NULL DEFAULT '',"
4674 " inetref varchar(40) NOT NULL,"
4675 " search int(10) unsigned NOT NULL DEFAULT '0',"
4676 " autotranscode tinyint(1) NOT NULL DEFAULT '0',"
4677 " autocommflag tinyint(1) NOT NULL DEFAULT '0',"
4678 " autouserjob1 tinyint(1) NOT NULL DEFAULT '0',"
4679 " autouserjob2 tinyint(1) NOT NULL DEFAULT '0',"
4680 " autouserjob3 tinyint(1) NOT NULL DEFAULT '0',"
4681 " autouserjob4 tinyint(1) NOT NULL DEFAULT '0',"
4682 " autometadata tinyint(1) NOT NULL DEFAULT '0',"
4683 " findday tinyint(4) NOT NULL DEFAULT '0',"
4684 " findtime time NOT NULL DEFAULT '00:00:00',"
4685 " findid int(11) NOT NULL DEFAULT '0',"
4686 " inactive tinyint(1) NOT NULL DEFAULT '0',"
4687 " parentid int(11) NOT NULL DEFAULT '0',"
4688 " transcoder int(11) NOT NULL DEFAULT '0',"
4689 " playgroup varchar(32) NOT NULL DEFAULT 'Default',"
4690 " prefinput int(10) NOT NULL DEFAULT '0',"
4691 " next_record datetime NOT NULL,"
4692 " last_record datetime NOT NULL,"
4693 " last_delete datetime NOT NULL,"
4694 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4695 " avg_delay int(11) NOT NULL DEFAULT '100',"
4696 " filter int(10) unsigned NOT NULL DEFAULT '0',"
4697 " PRIMARY KEY (recordid),"
4698 " KEY chanid (chanid,starttime),"
4699 " KEY title (title),"
4700 " KEY seriesid (seriesid),"
4701 " KEY programid (programid),"
4702 " KEY maxepisodes (maxepisodes),"
4703 " KEY search (search),"
4704 " KEY `type` (`type`)"
4705 ") ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;",
4706 "CREATE TABLE recorded ("
4707 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4708 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4709 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4710 " title varchar(128) NOT NULL DEFAULT '',"
4711 " subtitle varchar(128) NOT NULL DEFAULT '',"
4712 " description varchar(16000) NOT NULL DEFAULT '',"
4713 " season smallint(5) NOT NULL,"
4714 " episode smallint(5) NOT NULL,"
4715 " category varchar(64) NOT NULL DEFAULT '',"
4716 " hostname varchar(64) NOT NULL DEFAULT '',"
4717 " bookmark tinyint(1) NOT NULL DEFAULT '0',"
4718 " editing int(10) unsigned NOT NULL DEFAULT '0',"
4719 " cutlist tinyint(1) NOT NULL DEFAULT '0',"
4720 " autoexpire int(11) NOT NULL DEFAULT '0',"
4721 " commflagged int(10) unsigned NOT NULL DEFAULT '0',"
4722 " recgroup varchar(32) NOT NULL DEFAULT 'Default',"
4723 " recordid int(11) DEFAULT NULL,"
4724 " seriesid varchar(40) NOT NULL DEFAULT '',"
4725 " programid varchar(40) NOT NULL DEFAULT '',"
4726 " inetref varchar(40) NOT NULL,"
4727 " lastmodified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4728 " filesize bigint(20) NOT NULL DEFAULT '0',"
4729 " stars float NOT NULL DEFAULT '0',"
4730 " previouslyshown tinyint(1) DEFAULT '0',"
4731 " originalairdate date DEFAULT NULL,"
4732 " `preserve` tinyint(1) NOT NULL DEFAULT '0',"
4733 " findid int(11) NOT NULL DEFAULT '0',"
4734 " deletepending tinyint(1) NOT NULL DEFAULT '0',"
4735 " transcoder int(11) NOT NULL DEFAULT '0',"
4736 " timestretch float NOT NULL DEFAULT '1',"
4737 " recpriority int(11) NOT NULL DEFAULT '0',"
4738 " basename varchar(255) NOT NULL,"
4739 " progstart datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4740 " progend datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4741 " playgroup varchar(32) NOT NULL DEFAULT 'Default',"
4742 " `profile` varchar(32) NOT NULL DEFAULT '',"
4743 " `duplicate` tinyint(1) NOT NULL DEFAULT '0',"
4744 " transcoded tinyint(1) NOT NULL DEFAULT '0',"
4745 " watched tinyint(4) NOT NULL DEFAULT '0',"
4746 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4747 " bookmarkupdate timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',"
4748 " PRIMARY KEY (chanid,starttime),"
4749 " KEY endtime (endtime),"
4750 " KEY seriesid (seriesid),"
4751 " KEY programid (programid),"
4752 " KEY title (title),"
4753 " KEY recordid (recordid),"
4754 " KEY deletepending (deletepending,lastmodified),"
4755 " KEY recgroup (recgroup,endtime)"
4756 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4757 "CREATE TABLE recordedartwork ("
4758 " inetref varchar(255) NOT NULL,"
4759 " season smallint(5) NOT NULL,"
4760 " `host` text NOT NULL,"
4761 " coverart text NOT NULL,"
4762 " fanart text NOT NULL,"
4763 " banner text NOT NULL"
4764 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4765 "CREATE TABLE recordedcredits ("
4766 " person mediumint(8) unsigned NOT NULL DEFAULT '0',"
4767 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4768 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4769 " role set('actor','director','producer','executive_producer','writer','guest_star','host','adapter','presenter','commentator','guest') NOT NULL DEFAULT '',"
4770 " UNIQUE KEY chanid (chanid,starttime,person,role),"
4771 " KEY person (person,role)"
4772 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4773 "CREATE TABLE recordedfile ("
4774 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4775 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4776 " basename varchar(128) NOT NULL DEFAULT '',"
4777 " filesize bigint(20) NOT NULL DEFAULT '0',"
4778 " width smallint(5) unsigned NOT NULL DEFAULT '0',"
4779 " height smallint(5) unsigned NOT NULL DEFAULT '0',"
4780 " fps float(6,3) NOT NULL DEFAULT '0.000',"
4781 " aspect float(8,6) NOT NULL DEFAULT '0.000000',"
4782 " audio_sample_rate smallint(5) unsigned NOT NULL DEFAULT '0',"
4783 " audio_bits_per_sample smallint(5) unsigned NOT NULL DEFAULT '0',"
4784 " audio_channels tinyint(3) unsigned NOT NULL DEFAULT '0',"
4785 " audio_type varchar(255) NOT NULL DEFAULT '',"
4786 " video_type varchar(255) NOT NULL DEFAULT '',"
4787 " `comment` varchar(255) NOT NULL DEFAULT '',"
4788 " hostname varchar(64) NOT NULL,"
4789 " storagegroup varchar(32) NOT NULL,"
4790 " id int(11) NOT NULL AUTO_INCREMENT,"
4791 " PRIMARY KEY (id),"
4792 " UNIQUE KEY chanid (chanid,starttime,basename),"
4793 " KEY basename (basename)"
4794 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4795 "CREATE TABLE recordedmarkup ("
4796 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4797 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4798 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4799 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4800 " `data` int(11) unsigned DEFAULT NULL,"
4801 " PRIMARY KEY (chanid,starttime,`type`,mark)"
4802 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4803 "CREATE TABLE recordedprogram ("
4804 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4805 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4806 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4807 " title varchar(128) NOT NULL DEFAULT '',"
4808 " subtitle varchar(128) NOT NULL DEFAULT '',"
4809 " description varchar(16000) NOT NULL DEFAULT '',"
4810 " category varchar(64) NOT NULL DEFAULT '',"
4811 " category_type varchar(64) NOT NULL DEFAULT '',"
4812 " airdate year(4) NOT NULL DEFAULT '0000',"
4813 " stars float unsigned NOT NULL DEFAULT '0',"
4814 " previouslyshown tinyint(4) NOT NULL DEFAULT '0',"
4815 " title_pronounce varchar(128) NOT NULL DEFAULT '',"
4816 " stereo tinyint(1) NOT NULL DEFAULT '0',"
4817 " subtitled tinyint(1) NOT NULL DEFAULT '0',"
4818 " hdtv tinyint(1) NOT NULL DEFAULT '0',"
4819 " closecaptioned tinyint(1) NOT NULL DEFAULT '0',"
4820 " partnumber int(11) NOT NULL DEFAULT '0',"
4821 " parttotal int(11) NOT NULL DEFAULT '0',"
4822 " seriesid varchar(40) NOT NULL DEFAULT '',"
4823 " originalairdate date DEFAULT NULL,"
4824 " showtype varchar(30) NOT NULL DEFAULT '',"
4825 " colorcode varchar(20) NOT NULL DEFAULT '',"
4826 " syndicatedepisodenumber varchar(20) NOT NULL DEFAULT '',"
4827 " programid varchar(40) NOT NULL DEFAULT '',"
4828 " manualid int(10) unsigned NOT NULL DEFAULT '0',"
4829 " generic tinyint(1) DEFAULT '0',"
4830 " listingsource int(11) NOT NULL DEFAULT '0',"
4831 " `first` tinyint(1) NOT NULL DEFAULT '0',"
4832 " `last` tinyint(1) NOT NULL DEFAULT '0',"
4833 " audioprop set('STEREO','MONO','SURROUND','DOLBY','HARDHEAR','VISUALIMPAIR') NOT NULL,"
4834 " subtitletypes set('HARDHEAR','NORMAL','ONSCREEN','SIGNED') NOT NULL,"
4835 " videoprop set('HDTV','WIDESCREEN','AVC','720','1080','DAMAGED') NOT NULL,"
4836 " PRIMARY KEY (chanid,starttime,manualid),"
4837 " KEY endtime (endtime),"
4838 " KEY title (title),"
4839 " KEY title_pronounce (title_pronounce),"
4840 " KEY seriesid (seriesid),"
4841 " KEY programid (programid),"
4842 " KEY id_start_end (chanid,starttime,endtime)"
4843 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4844 "CREATE TABLE recordedrating ("
4845 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4846 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4847 " `system` varchar(8) DEFAULT NULL,"
4848 " rating varchar(16) DEFAULT NULL,"
4849 " UNIQUE KEY chanid (chanid,starttime,`system`,rating),"
4850 " KEY starttime (starttime,`system`)"
4851 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4852 "CREATE TABLE recordedseek ("
4853 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4854 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4855 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4856 " `offset` bigint(20) unsigned NOT NULL,"
4857 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4858 " PRIMARY KEY (chanid,starttime,`type`,mark)"
4859 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4860 "CREATE TABLE recordfilter ("
4861 " filterid int(10) unsigned NOT NULL,"
4862 " description varchar(64) DEFAULT NULL,"
4863 " clause varchar(256) DEFAULT NULL,"
4864 " newruledefault tinyint(1) DEFAULT '0',"
4865 " PRIMARY KEY (filterid)"
4866 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4867 "CREATE TABLE recordingprofiles ("
4868 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4869 " `name` varchar(128) DEFAULT NULL,"
4870 " videocodec varchar(128) DEFAULT NULL,"
4871 " audiocodec varchar(128) DEFAULT NULL,"
4872 " profilegroup int(10) unsigned NOT NULL DEFAULT '0',"
4873 " PRIMARY KEY (id),"
4874 " KEY profilegroup (profilegroup)"
4875 ") ENGINE=MyISAM AUTO_INCREMENT=70 DEFAULT CHARSET=utf8;",
4876 "CREATE TABLE recordmatch ("
4877 " recordid int(10) unsigned NOT NULL,"
4878 " chanid int(10) unsigned NOT NULL,"
4879 " starttime datetime NOT NULL,"
4880 " manualid int(10) unsigned NOT NULL,"
4881 " oldrecduplicate tinyint(1) DEFAULT NULL,"
4882 " recduplicate tinyint(1) DEFAULT NULL,"
4883 " findduplicate tinyint(1) DEFAULT NULL,"
4884 " oldrecstatus int(11) DEFAULT NULL,"
4885 " findid int(11) NOT NULL DEFAULT '0',"
4886 " UNIQUE KEY recordid (recordid,chanid,starttime),"
4887 " KEY chanid (chanid,starttime,manualid),"
4888 " KEY recordid_2 (recordid,findid)"
4889 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4890 "CREATE TABLE scannerfile ("
4891 " fileid bigint(20) unsigned NOT NULL AUTO_INCREMENT,"
4892 " filesize bigint(20) unsigned NOT NULL DEFAULT '0',"
4893 " filehash varchar(64) NOT NULL DEFAULT '',"
4894 " added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
4895 " PRIMARY KEY (fileid),"
4896 " UNIQUE KEY filehash (filehash)"
4897 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4898 "CREATE TABLE scannerpath ("
4899 " fileid bigint(20) unsigned NOT NULL,"
4900 " hostname varchar(64) NOT NULL DEFAULT 'localhost',"
4901 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4902 " filename varchar(255) NOT NULL DEFAULT '',"
4903 " PRIMARY KEY (fileid)"
4904 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4905 "CREATE TABLE settings ("
4906 " `value` varchar(128) NOT NULL DEFAULT '',"
4907 " `data` varchar(16000) NOT NULL DEFAULT '',"
4908 " hostname varchar(64) DEFAULT NULL,"
4909 " KEY `value` (`value`,hostname)"
4910 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4911 "CREATE TABLE storagegroup ("
4912 " id int(11) NOT NULL AUTO_INCREMENT,"
4913 " groupname varchar(32) NOT NULL,"
4914 " hostname varchar(64) NOT NULL DEFAULT '',"
4915 " dirname varchar(235) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4916 " PRIMARY KEY (id),"
4917 " UNIQUE KEY grouphostdir (groupname,hostname,dirname),"
4918 " KEY hostname (hostname)"
4919 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4920 "CREATE TABLE tvchain ("
4921 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4922 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4923 " chainid varchar(128) NOT NULL DEFAULT '',"
4924 " chainpos int(10) NOT NULL DEFAULT '0',"
4925 " discontinuity tinyint(1) NOT NULL DEFAULT '0',"
4926 " watching int(10) NOT NULL DEFAULT '0',"
4927 " hostprefix varchar(128) NOT NULL DEFAULT '',"
4928 " cardtype varchar(32) NOT NULL DEFAULT 'V4L',"
4929 " input varchar(32) NOT NULL DEFAULT '',"
4930 " channame varchar(32) NOT NULL DEFAULT '',"
4931 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4932 " PRIMARY KEY (chanid,starttime)"
4933 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4934 "CREATE TABLE tvosdmenu ("
4935 " osdcategory varchar(32) NOT NULL,"
4936 " livetv tinyint(4) NOT NULL DEFAULT '0',"
4937 " recorded tinyint(4) NOT NULL DEFAULT '0',"
4938 " video tinyint(4) NOT NULL DEFAULT '0',"
4939 " dvd tinyint(4) NOT NULL DEFAULT '0',"
4940 " description varchar(32) NOT NULL,"
4941 " PRIMARY KEY (osdcategory)"
4942 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4943 "CREATE TABLE upnpmedia ("
4944 " intid int(10) unsigned NOT NULL DEFAULT '0',"
4945 " class varchar(64) NOT NULL DEFAULT '',"
4946 " itemtype varchar(128) NOT NULL DEFAULT '',"
4947 " parentid int(10) unsigned NOT NULL DEFAULT '0',"
4948 " itemproperties varchar(255) NOT NULL DEFAULT '',"
4949 " filepath varchar(512) NOT NULL DEFAULT '',"
4950 " title varchar(255) NOT NULL DEFAULT '',"
4951 " filename varchar(512) NOT NULL DEFAULT '',"
4952 " coverart varchar(512) NOT NULL DEFAULT '',"
4953 " PRIMARY KEY (intid),"
4954 " KEY class (class),"
4955 " KEY filepath (filepath(333)),"
4956 " KEY parentid (parentid)"
4957 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4958 "CREATE TABLE videocast ("
4959 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4960 " cast varchar(128) NOT NULL,"
4961 " PRIMARY KEY (intid)"
4962 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4963 "CREATE TABLE videocategory ("
4964 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4965 " category varchar(128) NOT NULL,"
4966 " PRIMARY KEY (intid)"
4967 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4968 "CREATE TABLE videocollection ("
4969 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4970 " title varchar(256) NOT NULL,"
4971 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
4972 " plot text,"
4973 " network varchar(128) DEFAULT NULL,"
4974 " collectionref varchar(128) NOT NULL,"
4975 " certification varchar(128) DEFAULT NULL,"
4976 " genre varchar(128) DEFAULT '',"
4977 " releasedate date DEFAULT NULL,"
4978 " `language` varchar(10) DEFAULT NULL,"
4979 " `status` varchar(64) DEFAULT NULL,"
4980 " rating float DEFAULT '0',"
4981 " ratingcount int(10) DEFAULT '0',"
4982 " runtime smallint(5) unsigned DEFAULT '0',"
4983 " banner text,"
4984 " fanart text,"
4985 " coverart text,"
4986 " PRIMARY KEY (intid),"
4987 " KEY title (title)"
4988 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4989 "CREATE TABLE videocountry ("
4990 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4991 " country varchar(128) NOT NULL,"
4992 " PRIMARY KEY (intid)"
4993 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4994 "CREATE TABLE videogenre ("
4995 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4996 " genre varchar(128) NOT NULL,"
4997 " PRIMARY KEY (intid)"
4998 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4999 "CREATE TABLE videometadata ("
5000 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
5001 " title varchar(128) NOT NULL,"
5002 " subtitle text NOT NULL,"
5003 " tagline varchar(255) DEFAULT NULL,"
5004 " director varchar(128) NOT NULL,"
5005 " studio varchar(128) DEFAULT NULL,"
5006 " plot text,"
5007 " rating varchar(128) NOT NULL,"
5008 " inetref varchar(255) NOT NULL,"
5009 " collectionref int(10) NOT NULL DEFAULT '-1',"
5010 " homepage text NOT NULL,"
5011 " `year` int(10) unsigned NOT NULL,"
5012 " releasedate date NOT NULL,"
5013 " userrating float NOT NULL,"
5014 " length int(10) unsigned NOT NULL,"
5015 " playcount int(10) NOT NULL DEFAULT '0',"
5016 " season smallint(5) unsigned NOT NULL DEFAULT '0',"
5017 " episode smallint(5) unsigned NOT NULL DEFAULT '0',"
5018 " showlevel int(10) unsigned NOT NULL,"
5019 " filename text NOT NULL,"
5020 " `hash` varchar(128) NOT NULL,"
5021 " coverfile text NOT NULL,"
5022 " childid int(11) NOT NULL DEFAULT '-1',"
5023 " browse tinyint(1) NOT NULL DEFAULT '1',"
5024 " watched tinyint(1) NOT NULL DEFAULT '0',"
5025 " processed tinyint(1) NOT NULL DEFAULT '0',"
5026 " playcommand varchar(255) DEFAULT NULL,"
5027 " category int(10) unsigned NOT NULL DEFAULT '0',"
5028 " trailer text,"
5029 " `host` text NOT NULL,"
5030 " screenshot text,"
5031 " banner text,"
5032 " fanart text,"
5033 " insertdate timestamp NULL DEFAULT CURRENT_TIMESTAMP,"
5034 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
5035 " PRIMARY KEY (intid),"
5036 " KEY director (director),"
5037 " KEY title (title)"
5038 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5039 "CREATE TABLE videometadatacast ("
5040 " idvideo int(10) unsigned NOT NULL,"
5041 " idcast int(10) unsigned NOT NULL,"
5042 " UNIQUE KEY idvideo (idvideo,idcast)"
5043 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5044 "CREATE TABLE videometadatacountry ("
5045 " idvideo int(10) unsigned NOT NULL,"
5046 " idcountry int(10) unsigned NOT NULL,"
5047 " UNIQUE KEY idvideo_2 (idvideo,idcountry),"
5048 " KEY idvideo (idvideo),"
5049 " KEY idcountry (idcountry)"
5050 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5051 "CREATE TABLE videometadatagenre ("
5052 " idvideo int(10) unsigned NOT NULL,"
5053 " idgenre int(10) unsigned NOT NULL,"
5054 " UNIQUE KEY idvideo_2 (idvideo,idgenre),"
5055 " KEY idvideo (idvideo),"
5056 " KEY idgenre (idgenre)"
5057 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5058 "CREATE TABLE videopart ("
5059 " fileid bigint(20) unsigned NOT NULL,"
5060 " videoid int(10) unsigned NOT NULL,"
5061 " `order` smallint(5) unsigned NOT NULL DEFAULT '1',"
5062 " PRIMARY KEY (videoid,`order`)"
5063 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5064 "CREATE TABLE videopathinfo ("
5065 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
5066 " path text,"
5067 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
5068 " collectionref int(10) DEFAULT '0',"
5069 " recurse tinyint(1) DEFAULT '0',"
5070 " PRIMARY KEY (intid)"
5071 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5072 "CREATE TABLE videosource ("
5073 " sourceid int(10) unsigned NOT NULL AUTO_INCREMENT,"
5074 " `name` varchar(128) NOT NULL DEFAULT '',"
5075 " xmltvgrabber varchar(128) DEFAULT NULL,"
5076 " userid varchar(128) NOT NULL DEFAULT '',"
5077 " freqtable varchar(16) NOT NULL DEFAULT 'default',"
5078 " lineupid varchar(64) DEFAULT NULL,"
5079 " `password` varchar(64) DEFAULT NULL,"
5080 " useeit smallint(6) NOT NULL DEFAULT '0',"
5081 " configpath varchar(4096) DEFAULT NULL,"
5082 " dvb_nit_id int(6) DEFAULT '-1',"
5083 " PRIMARY KEY (sourceid),"
5084 " UNIQUE KEY `name` (`name`)"
5085 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5086 "CREATE TABLE videotypes ("
5087 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
5088 " extension varchar(128) NOT NULL,"
5089 " playcommand varchar(255) NOT NULL,"
5090 " f_ignore tinyint(1) DEFAULT NULL,"
5091 " use_default tinyint(1) DEFAULT NULL,"
5092 " PRIMARY KEY (intid)"
5093 ") ENGINE=MyISAM AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;",
5094 
5095 "INSERT INTO channelgroupnames VALUES (1,'Favorites');",
5096 R"(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);)", "INSERT INTO dtv_privatetypes VALUES ('dvb',9018,'channel_numbers','131');", "INSERT INTO dtv_privatetypes VALUES ('dvb',9018,'guide_fixup','2');", "INSERT INTO dtv_privatetypes VALUES ('dvb',256,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',257,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',256,'tv_types','1,150,134,133');", "INSERT INTO dtv_privatetypes VALUES ('dvb',257,'tv_types','1,150,134,133');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4100,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4101,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4102,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4103,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4104,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4105,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4106,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4107,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4097,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4098,'sdt_mapping','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4100,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4101,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4102,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4103,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4104,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4105,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4106,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4107,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4097,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4098,'tv_types','1,145,154');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4100,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4101,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4102,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4103,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4104,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4105,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4106,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4107,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4096,'guide_fixup','5');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4097,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4098,'guide_fixup','1');", "INSERT INTO dtv_privatetypes VALUES ('dvb',94,'tv_types','1,128');", "INSERT INTO dtv_privatetypes VALUES ('atsc',1793,'guide_fixup','3');", "INSERT INTO dtv_privatetypes VALUES ('dvb',40999,'guide_fixup','4');", "INSERT INTO dtv_privatetypes VALUES ('dvb',70,'force_guide_present','yes');", "INSERT INTO dtv_privatetypes VALUES ('dvb',70,'guide_ranges','80,80,96,96');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4112,'channel_numbers','131');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4115,'channel_numbers','131');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4116,'channel_numbers','131');", "INSERT INTO dtv_privatetypes VALUES ('dvb',12802,'channel_numbers','131');", "INSERT INTO dtv_privatetypes VALUES ('dvb',12803,'channel_numbers','131');", "INSERT INTO dtv_privatetypes VALUES ('dvb',12829,'channel_numbers','131');", "INSERT INTO dtv_privatetypes VALUES ('dvb',40999,'parse_subtitle_list','1070,1308,1041,1306,1307,1030,1016,1131,1068,1069');", "INSERT INTO dtv_privatetypes VALUES ('dvb',4096,'guide_fixup','5');", "INSERT INTO dvdinput VALUES (1,720,480,16,9,1,1,'ntsc');", "INSERT INTO dvdinput VALUES (2,720,480,16,9,1,0,'ntsc');", "INSERT INTO dvdinput VALUES (3,720,480,4,3,1,1,'ntsc');", "INSERT INTO dvdinput VALUES (4,720,480,4,3,1,0,'ntsc');", "INSERT INTO dvdinput VALUES (5,720,576,16,9,3,1,'pal');", "INSERT INTO dvdinput VALUES (6,720,576,16,9,3,0,'pal');", "INSERT INTO dvdinput VALUES (7,720,576,4,3,3,1,'pal');", "INSERT INTO dvdinput VALUES (8,720,576,4,3,3,0,'pal');", "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);", "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);", "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);", "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);", "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);", "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);", "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);", "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);", "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);", "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);", "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);", "INSERT INTO playgroup VALUES ('Default','',30,5,100,0);", "INSERT INTO profilegroups VALUES (1,'Software Encoders (v4l based)','V4L',1,NULL);", "INSERT INTO profilegroups VALUES (2,'IVTV MPEG-2 Encoders','MPEG',1,NULL);", "INSERT INTO profilegroups VALUES (3,'Hardware MJPEG Encoders (Matrox G200-TV, Miro DC10, etc)','MJPEG',1,NULL);", "INSERT INTO profilegroups VALUES (4,'Hardware HDTV','HDTV',1,NULL);", "INSERT INTO profilegroups VALUES (5,'Hardware DVB Encoders','DVB',1,NULL);", "INSERT INTO profilegroups VALUES (6,'Transcoders','TRANSCODE',1,NULL);", "INSERT INTO profilegroups VALUES (7,'FireWire Input','FIREWIRE',1,NULL);", "INSERT INTO profilegroups VALUES (8,'USB Mpeg-4 Encoder (Plextor ConvertX, etc)','GO7007',1,NULL);", "INSERT INTO profilegroups VALUES (14,'Import Recorder','IMPORT',1,NULL);", "INSERT INTO profilegroups VALUES (10,'Freebox Input','Freebox',1,NULL);", "INSERT INTO profilegroups VALUES (11,'HDHomeRun Recorders','HDHOMERUN',1,NULL);", "INSERT INTO profilegroups VALUES (12,'CRC IP Recorders','CRC_IP',1,NULL);", "INSERT INTO profilegroups VALUES (13,'HD-PVR Recorders','HDPVR',1,NULL);", "INSERT INTO profilegroups VALUES (15,'ASI Recorder (DVEO)','ASI',1,NULL);", "INSERT INTO profilegroups VALUES (16,'OCUR Recorder (CableLabs)','OCUR',1,NULL);", "INSERT INTO profilegroups VALUES (17,'Ceton Recorder','CETON',1,NULL);", "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);", "INSERT INTO recordfilter VALUES (0,'New episode','program.previouslyshown = 0',0);", "INSERT INTO recordfilter VALUES (1,'Identifiable episode','program.generic = 0',0);", "INSERT INTO recordfilter VALUES (2,'First showing','program.first > 0',0);", R"(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);)", "INSERT INTO recordfilter VALUES (4,'Commercial free','channel.commmethod = -2',0);", "INSERT INTO recordfilter VALUES (5,'High definition','program.hdtv > 0',0);", R"(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);)", "INSERT INTO recordfilter VALUES (7,'This series','(RECTABLE.seriesid <> \\'\\' AND program.seriesid = RECTABLE.seriesid)',0);", "INSERT INTO recordingprofiles VALUES (1,'Default',NULL,NULL,1);", "INSERT INTO recordingprofiles VALUES (2,'Live TV',NULL,NULL,1);", "INSERT INTO recordingprofiles VALUES (3,'High Quality',NULL,NULL,1);", "INSERT INTO recordingprofiles VALUES (4,'Low Quality',NULL,NULL,1);", "INSERT INTO recordingprofiles VALUES (5,'Default',NULL,NULL,2);", "INSERT INTO recordingprofiles VALUES (6,'Live TV',NULL,NULL,2);", "INSERT INTO recordingprofiles VALUES (7,'High Quality',NULL,NULL,2);", "INSERT INTO recordingprofiles VALUES (8,'Low Quality',NULL,NULL,2);", "INSERT INTO recordingprofiles VALUES (9,'Default',NULL,NULL,3);", "INSERT INTO recordingprofiles VALUES (10,'Live TV',NULL,NULL,3);", "INSERT INTO recordingprofiles VALUES (11,'High Quality',NULL,NULL,3);", "INSERT INTO recordingprofiles VALUES (12,'Low Quality',NULL,NULL,3);", "INSERT INTO recordingprofiles VALUES (13,'Default',NULL,NULL,4);", "INSERT INTO recordingprofiles VALUES (14,'Live TV',NULL,NULL,4);", "INSERT INTO recordingprofiles VALUES (15,'High Quality',NULL,NULL,4);", "INSERT INTO recordingprofiles VALUES (16,'Low Quality',NULL,NULL,4);", "INSERT INTO recordingprofiles VALUES (17,'Default',NULL,NULL,5);", "INSERT INTO recordingprofiles VALUES (18,'Live TV',NULL,NULL,5);", "INSERT INTO recordingprofiles VALUES (19,'High Quality',NULL,NULL,5);", "INSERT INTO recordingprofiles VALUES (20,'Low Quality',NULL,NULL,5);", "INSERT INTO recordingprofiles VALUES (21,'RTjpeg/MPEG4',NULL,NULL,6);", "INSERT INTO recordingprofiles VALUES (22,'MPEG2',NULL,NULL,6);", "INSERT INTO recordingprofiles VALUES (23,'Default',NULL,NULL,8);", "INSERT INTO recordingprofiles VALUES (24,'Live TV',NULL,NULL,8);", "INSERT INTO recordingprofiles VALUES (25,'High Quality',NULL,NULL,8);", "INSERT INTO recordingprofiles VALUES (26,'Low Quality',NULL,NULL,8);", "INSERT INTO recordingprofiles VALUES (27,'High Quality',NULL,NULL,6);", "INSERT INTO recordingprofiles VALUES (28,'Medium Quality',NULL,NULL,6);", "INSERT INTO recordingprofiles VALUES (29,'Low Quality',NULL,NULL,6);", "INSERT INTO recordingprofiles VALUES (30,'Default',NULL,NULL,10);", "INSERT INTO recordingprofiles VALUES (31,'Live TV',NULL,NULL,10);", "INSERT INTO recordingprofiles VALUES (32,'High Quality',NULL,NULL,10);", "INSERT INTO recordingprofiles VALUES (33,'Low Quality',NULL,NULL,10);", "INSERT INTO recordingprofiles VALUES (34,'Default',NULL,NULL,11);", "INSERT INTO recordingprofiles VALUES (35,'Live TV',NULL,NULL,11);", "INSERT INTO recordingprofiles VALUES (36,'High Quality',NULL,NULL,11);", "INSERT INTO recordingprofiles VALUES (37,'Low Quality',NULL,NULL,11);", "INSERT INTO recordingprofiles VALUES (38,'Default',NULL,NULL,12);", "INSERT INTO recordingprofiles VALUES (39,'Live TV',NULL,NULL,12);", "INSERT INTO recordingprofiles VALUES (40,'High Quality',NULL,NULL,12);", "INSERT INTO recordingprofiles VALUES (41,'Low Quality',NULL,NULL,12);", "INSERT INTO recordingprofiles VALUES (42,'Default',NULL,NULL,7);", "INSERT INTO recordingprofiles VALUES (43,'Live TV',NULL,NULL,7);", "INSERT INTO recordingprofiles VALUES (44,'High Quality',NULL,NULL,7);", "INSERT INTO recordingprofiles VALUES (45,'Low Quality',NULL,NULL,7);", "INSERT INTO recordingprofiles VALUES (46,'Default',NULL,NULL,9);", "INSERT INTO recordingprofiles VALUES (47,'Live TV',NULL,NULL,9);", "INSERT INTO recordingprofiles VALUES (48,'High Quality',NULL,NULL,9);", "INSERT INTO recordingprofiles VALUES (49,'Low Quality',NULL,NULL,9);", "INSERT INTO recordingprofiles VALUES (50,'Default',NULL,NULL,13);", "INSERT INTO recordingprofiles VALUES (51,'Live TV',NULL,NULL,13);", "INSERT INTO recordingprofiles VALUES (52,'High Quality',NULL,NULL,13);", "INSERT INTO recordingprofiles VALUES (53,'Low Quality',NULL,NULL,13);", "INSERT INTO recordingprofiles VALUES (54,'Default',NULL,NULL,14);", "INSERT INTO recordingprofiles VALUES (55,'Live TV',NULL,NULL,14);", "INSERT INTO recordingprofiles VALUES (56,'High Quality',NULL,NULL,14);", "INSERT INTO recordingprofiles VALUES (57,'Low Quality',NULL,NULL,14);", "INSERT INTO recordingprofiles VALUES (58,'Default',NULL,NULL,15);", "INSERT INTO recordingprofiles VALUES (59,'Live TV',NULL,NULL,15);", "INSERT INTO recordingprofiles VALUES (60,'High Quality',NULL,NULL,15);", "INSERT INTO recordingprofiles VALUES (61,'Low Quality',NULL,NULL,15);", "INSERT INTO recordingprofiles VALUES (62,'Default',NULL,NULL,16);", "INSERT INTO recordingprofiles VALUES (63,'Live TV',NULL,NULL,16);", "INSERT INTO recordingprofiles VALUES (64,'High Quality',NULL,NULL,16);", "INSERT INTO recordingprofiles VALUES (65,'Low Quality',NULL,NULL,16);", "INSERT INTO recordingprofiles VALUES (66,'Default',NULL,NULL,17);", "INSERT INTO recordingprofiles VALUES (67,'Live TV',NULL,NULL,17);", "INSERT INTO recordingprofiles VALUES (68,'High Quality',NULL,NULL,17);", "INSERT INTO recordingprofiles VALUES (69,'Low Quality',NULL,NULL,17);", "INSERT INTO settings VALUES ('mythfilldatabaseLastRunStart','',NULL);", "INSERT INTO settings VALUES ('mythfilldatabaseLastRunEnd','',NULL);", "INSERT INTO settings VALUES ('mythfilldatabaseLastRunStatus','',NULL);", "INSERT INTO settings VALUES ('DataDirectMessage','',NULL);", "INSERT INTO settings VALUES ('HaveRepeats','0',NULL);", "INSERT INTO settings VALUES ('DBSchemaVer','1307',NULL);", "INSERT INTO settings VALUES ('DefaultTranscoder','0',NULL);", "INSERT INTO videotypes VALUES (1,'txt','',1,0);", "INSERT INTO videotypes VALUES (2,'log','',1,0);", "INSERT INTO videotypes VALUES (3,'mpg','Internal',0,0);", "INSERT INTO videotypes VALUES (4,'avi','',0,1);", "INSERT INTO videotypes VALUES (5,'vob','Internal',0,0);", "INSERT INTO videotypes VALUES (6,'mpeg','Internal',0,0);", "INSERT INTO videotypes VALUES (8,'iso','Internal',0,0);", "INSERT INTO videotypes VALUES (9,'img','Internal',0,0);", "INSERT INTO videotypes VALUES (10,'mkv','Internal',0,0);", "INSERT INTO videotypes VALUES (11,'mp4','Internal',0,0);", "INSERT INTO videotypes VALUES (12,'m2ts','Internal',0,0);", "INSERT INTO videotypes VALUES (13,'evo','Internal',0,0);", "INSERT INTO videotypes VALUES (14,'divx','Internal',0,0);", "INSERT INTO videotypes VALUES (15,'mov','Internal',0,0);", "INSERT INTO videotypes VALUES (16,'qt','Internal',0,0);", "INSERT INTO videotypes VALUES (17,'wmv','Internal',0,0);", "INSERT INTO videotypes VALUES (18,'3gp','Internal',0,0);", "INSERT INTO videotypes VALUES (19,'asf','Internal',0,0);", "INSERT INTO videotypes VALUES (20,'ogg','Internal',0,0);", "INSERT INTO videotypes VALUES (21,'ogm','Internal',0,0);", "INSERT INTO videotypes VALUES (22,'flv','Internal',0,0);", "INSERT INTO videotypes VALUES (23,'ogv','Internal',0,0);", "INSERT INTO videotypes VALUES (25,'nut','Internal',0,0);", "INSERT INTO videotypes VALUES (26,'mxf','Internal',0,0);", "INSERT INTO videotypes VALUES (27,'m4v','Internal',0,0);", "INSERT INTO videotypes VALUES (28,'rm','Internal',0,0);", "INSERT INTO videotypes VALUES (29,'ts','Internal',0,0);", "INSERT INTO videotypes VALUES (30,'swf','Internal',0,0);", "INSERT INTO videotypes VALUES (31,'f4v','Internal',0,0);", "INSERT INTO videotypes VALUES (32,'nuv','Internal',0,0);"
5097 };
5098 
5099  QString dbver = "";
5100  if (!performActualUpdate("MythTV", "DBSchemaVer",
5101  updates, "1307", dbver))
5102  return false;
5103 
5104  GetMythDB()->SetHaveSchema(true);
5105 
5106  return true;
5107 }
5108 
5109 DBUpdates getRecordingExtenderDbInfo (int version)
5110 {
5111  switch (version)
5112  {
5113  case -1:
5114  return {
5115  R"(DROP TABLE IF EXISTS sportscleanup;)",
5116  R"(DROP TABLE IF EXISTS sportslisting;)",
5117  R"(DROP TABLE IF EXISTS sportsapi;)",
5118  };
5119 
5120  case 0:
5121  return {
5122  R"(ALTER TABLE record ADD COLUMN autoextend
5123  TINYINT UNSIGNED DEFAULT 0;)",
5124  };
5125 
5126  case 1:
5127  return {
5128  R"(CREATE TABLE sportsapi (
5129  id INT UNSIGNED PRIMARY KEY,
5130  provider TINYINT UNSIGNED DEFAULT 0,
5131  name VARCHAR(128) NOT NULL,
5132  key1 VARCHAR(64) NOT NULL,
5133  key2 VARCHAR(64) NOT NULL,
5134  UNIQUE(provider,key1(25),key2(50))
5135  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;)",
5136  R"(INSERT INTO sportsapi
5137  VALUES
5138  ( 1,1,"Major League Baseball","baseball","mlb"),
5139  ( 2,1,"NCAA Men's Baseball","baseball","college-baseball"),
5140  ( 3,1,"NCAA Women's Softball","baseball","college-softball"),
5141  ( 4,1,"Olympic Men's Baseball","baseball","olympics-baseball"),
5142  ( 5,1,"World Baseball Classic","baseball","world-baseball-classic"),
5143  ( 6,1,"Little League Baseball","baseball","llb"),
5144  ( 7,1,"Caribbean Series","baseball","caribbean-series"),
5145  ( 8,1,"Dominican Winter League","baseball","dominican-winter-league"),
5146  ( 9,1,"Venezuelan Winter League","baseball","venezuelan-winter-league"),
5147  ( 10,1,"Mexican League","baseball","mexican-winter-league"),
5148  ( 11,1,"Puerto Rican Winter League","baseball","puerto-rican-winter-league");)",
5149 
5150  R"(INSERT INTO sportsapi
5151  VALUES
5152  ( 20,1,"National Football League","football","nfl"),
5153  ( 21,1,"NCAA - Football","football","college-football"),
5154  ( 22,1,"XFL","football","xfl"),
5155  ( 23,1,"Canadian Football League","football","cfl");)",
5156 
5157  R"(INSERT INTO sportsapi
5158  VALUES
5159  ( 40,1,"National Basketball Association","basketball","nba"),
5160  ( 41,1,"Women's National Basketball Association","basketball","wnba"),
5161  ( 42,1,"NCAA Men's Basketball","basketball","mens-college-basketball"),
5162  ( 43,1,"NCAA Women's Basketball","basketball","womens-college-basketball"),
5163  ( 44,1,"Olympics Men's Basketball","basketball","mens-olympic-basketball"),
5164  ( 45,1,"Olympics Women's Basketball","basketball","womens-olympic-basketball"),
5165  ( 46,1,"National Basketball Association Summer League Las Vegas","basketball","nba-summer-las-vegas"),
5166  ( 47,1,"National Basketball Association Summer League Utah","basketball","nba-summer-utah"),
5167  ( 48,1,"National Basketball Association Summer League Orlando","basketball","nba-summer-orlando"),
5168  ( 49,1,"National Basketball Association Summer League Sacramento","basketball","nba-summer-sacramento"),
5169  ( 50,1,"NBA G League","basketball","nba-development"),
5170  ( 51,1,"International Basketball Federation","basketball","fiba");)",
5171 
5172  R"(INSERT INTO sportsapi
5173  VALUES
5174  ( 60,1,"National Hockey League","hockey","nfl"),
5175  ( 61,1,"NCAA Men's Ice Hockey","hockey","mens-college-hockey"),
5176  ( 62,1,"NCAA Women's Hockey","hockey","womens-college-hockey"),
5177  ( 63,1,"World Cup of Hockey","hockey","hockey-world-cup"),
5178  ( 64,1,"Men's Olympic Ice Hockey","hockey","mens-olympic-hockey"),
5179  ( 65,1,"Women's Olympic Ice Hockey","hockey","womens-olympic-hockey"),
5180  ( 66,1,"NCAA Women's Field Hockey","field-hockey","womens-college-field-hockey");)",
5181 
5182  R"(INSERT INTO sportsapi
5183  VALUES
5184  ( 80,1,"NCAA Men's Volleyball","volleyball","mens-college-volleyball"),
5185  ( 81,1,"NCAA Women's Volleyball","volleyball","womens-college-volleyball");)",
5186 
5187  R"(INSERT INTO sportsapi
5188  VALUES
5189  ( 100,1,"NCAA Men's Lacrosse","lacrosse","mens-college-lacrosse"),
5190  ( 101,1,"NCAA Women's Lacrosse","lacrosse","womens-college-lacrosse");)",
5191 
5192  R"(INSERT INTO sportsapi
5193  VALUES
5194  ( 120,1,"NCAA Men's Water Polo","water-polo","mens-college-water-polo"),
5195  ( 121,1,"NCAA Women's Water Polo","water-polo","womens-college-water-polo");)",
5196 
5197  R"(INSERT INTO sportsapi
5198  VALUES
5199  ( 200,1,"NCAA Men's Soccer","soccer","usa.ncaa.m.1"),
5200  ( 201,1,"NCAA Women's Soccer","soccer","usa.ncaa.w.1"),
5201  ( 202,1,"Major League Soccer","soccer","usa.1"),
5202  ( 203,1,"English Premier League","soccer","eng.1"),
5203  ( 204,1,"English League Championship","soccer","eng.2"),
5204  ( 205,1,"Italian Serie A","soccer","ita.1"),
5205  ( 206,1,"French Ligue 1","soccer","fra.1"),
5206  ( 207,1,"French Ligue 2","soccer","fra.2"),
5207  ( 208,1,"Spanish LaLiga","soccer","esp.1"),
5208  ( 209,1,"German Bundesliga","soccer","ger.1"),
5209  ( 210,1,"German 2. Bundesliga","soccer","ger.2"),
5210  ( 211,1,"Mexican Liga BBVA MX","soccer","mex.1"),
5211  ( 212,1,"Copa Do Brasil","soccer","bra.copa_do_brazil"),
5212  ( 213,1,"CONCACAF Leagues Cup","soccer","concacaf.leagues.cup"),
5213  ( 214,1,"CONCACAF League","soccer","concacaf.league"),
5214  ( 215,1,"CONCACAF Champions League","soccer","concacaf.champions"),
5215  ( 216,1,"CONCACAF Nations League","soccer","concacaf.nations.league"),
5216  ( 217,1,"CONCACAF Gold Cup","soccer","concacaf.gold"),
5217  ( 218,1,"FIFA World Cup","soccer","fifa.world"),
5218  ( 219,1,"FIFA World Cup Qualifying - UEFA","soccer","fifa.worldq.uefa"),
5219  ( 220,1,"FIFA World Cup Qualifying - CONCACAF","soccer","fifa.worldq.concacaf"),
5220  ( 221,1,"FIFA World Cup Qualifying - CONMEBOL","soccer","fifa.worldq.conmebol"),
5221  ( 222,1,"FIFA World Cup Qualifying - AFC","soccer","fifa.worldq.afc"),
5222  ( 223,1,"FIFA World Cup Qualifying - CAF","soccer","fifa.worldq.caf"),
5223  ( 224,1,"FIFA World Cup Qualifying - OFC","soccer","fifa.worldq.ofc"),
5224  ( 225,1,"UEFA Champions League","soccer","uefa.champions"),
5225  ( 226,1,"UEFA Europa League","soccer","uefa.europa"),
5226  ( 227,1,"UEFA Europa Conference League","soccer","uefa.europa.conf"),
5227  ( 228,1,"English Carabao Cup","soccer","eng.league_cup"),
5228  ( 229,1,"USL Championship","soccer","usa.usl.1"),
5229  ( 230,1,"United States NWSL","soccer","usa.nwsl"),
5230  ( 231,1,"FA Women's Super League","soccer","eng.w.1"),
5231  ( 232,1,"English FA Cup","soccer","eng.fa"),
5232  ( 233,1,"Spanish Copa del Rey","soccer","esp.copa_del_rey"),
5233  ( 234,1,"German DFB Pokal","soccer","ger.dfb_pokal"),
5234  ( 235,1,"Italian Coppa Italia","soccer","ita.coppa_italia"),
5235  ( 236,1,"French Coupe de France","soccer","fra.coupe_de_france"),
5236  ( 237,1,"AFC Champions League","soccer","afc.champions"),
5237  ( 238,1,"Dutch KNVB Beker","soccer","ned.cup"),
5238  ( 239,1,"Dutch Eredivisie","soccer","ned.1"),
5239  ( 240,1,"Portuguese Liga","soccer","por.1"),
5240  ( 241,1,"Russian Premier League","soccer","rus.1"),
5241  ( 242,1,"Mexican Liga de Expansión MX","soccer","mex.2"),
5242  ( 243,1,"Mexican Copa MX","soccer","mex.copa_mx"),
5243  ( 244,1,"Campeones Cup","soccer","campeones.cup"),
5244  ( 245,1,"United States Open Cup","soccer","usa.open"),
5245  ( 246,1,"USL League One","soccer","usa.usl.l1"),
5246  ( 247,1,"Scottish Premiership","soccer","sco.1"),
5247  ( 248,1,"Chinese Super League","soccer","chn.1"),
5248  ( 249,1,"Australian A-League","soccer","aus.1"),
5249  ( 250,1,"International Friendly","soccer","fifa.friendly"),
5250  ( 251,1,"Women's International Friendly","soccer","fifa.friendly.w"),
5251  ( 252,1,"UEFA European Under-21 Championship Qualifying","soccer","uefa.euro_u21_qual"),
5252  ( 253,1,"FIFA Women's World Cup","soccer","fifa.wwc"),
5253  ( 254,1,"FIFA Club World Cup","soccer","fifa.cwc"),
5254  ( 255,1,"CONCACAF Gold Cup Qualifying","soccer","concacaf.gold_qual"),
5255  ( 256,1,"CONCACAF Nations League Qualifying","soccer","concacaf.nations.league_qual"),
5256  ( 257,1,"CONCACAF Cup","soccer","concacaf.confederations_playoff"),
5257  ( 258,1,"UEFA Nations League","soccer","uefa.nations"),
5258  ( 259,1,"UEFA European Championship","soccer","uefa.euro"),
5259  ( 260,1,"UEFA European Championship Qualifying","soccer","uefa.euroq"),
5260  ( 261,1,"Copa America","soccer","conmebol.america"),
5261  ( 262,1,"AFC Asian Cup","soccer","afc.asian.cup"),
5262  ( 263,1,"AFC Asian Cup Qualifiers","soccer","afc.cupq"),
5263  ( 264,1,"Africa Cup of Nations qualifying","soccer","caf.nations_qual"),
5264  ( 265,1,"Africa Cup of Nations","soccer","caf.nations"),
5265  ( 266,1,"Africa Nations Championship","soccer","caf.championship"),
5266  ( 267,1,"WAFU Cup of Nations","soccer","wafu.nations"),
5267  ( 268,1,"SheBelieves Cup","soccer","fifa.shebelieves"),
5268  ( 269,1,"FIFA Confederations Cup","soccer","fifa.confederations"),
5269  ( 270,1,"Non-FIFA Friendly","soccer","nonfifa"),
5270  ( 271,1,"Spanish LaLiga 2","soccer","esp.2"),
5271  ( 272,1,"Spanish Supercopa","soccer","esp.super_cup"),
5272  ( 273,1,"Portuguese Liga Promotion/Relegation Playoffs","soccer","por.1.promotion.relegation"),
5273  ( 274,1,"Belgian First Division A - Promotion/Relegation Playoffs","soccer","bel.promotion.relegation"),
5274  ( 275,1,"Belgian First Division A","soccer","bel.1"),
5275  ( 276,1,"Austrian Bundesliga","soccer","aut.1"),
5276  ( 277,1,"Turkish Super Lig","soccer","tur.1"),
5277  ( 278,1,"Austrian Bundesliga Promotion/Relegation Playoffs","soccer","aut.promotion.relegation"),
5278  ( 279,1,"Greek Super League","soccer","gre.1"),
5279  ( 280,1,"Greek Super League Promotion/Relegation Playoffs","soccer","gre.1.promotion.relegation"),
5280  ( 281,1,"Swiss Super League","soccer","sui.1"),
5281  ( 282,1,"Swiss Super League Promotion/Relegation Playoffs","soccer","sui.1.promotion.relegation"),
5282  ( 283,1,"UEFA Women's Champions League","soccer","uefa.wchampions"),
5283  ( 284,1,"International Champions Cup","soccer","global.champs_cup"),
5284  ( 285,1,"Women's International Champions Cup","soccer","global.wchamps_cup"),
5285  ( 286,1,"Club Friendly","soccer","club.friendly"),
5286  ( 287,1,"UEFA Champions League Qualifying","soccer","uefa.champions_qual"),
5287  ( 288,1,"UEFA Europa Conference League Qualifying","soccer","uefa.europa.conf_qual"),
5288  ( 289,1,"UEFA Europa League Qualifying","soccer","uefa.europa_qual"),
5289  ( 290,1,"UEFA Super Cup","soccer","uefa.super_cup"),
5290  ( 291,1,"English FA Community Shield","soccer","eng.charity"),
5291  ( 292,1,"Supercoppa Italiana","soccer","ita.super_cup"),
5292  ( 293,1,"French Trophee des Champions","soccer","fra.super_cup"),
5293  ( 294,1,"Dutch Johan Cruyff Shield","soccer","ned.supercup"),
5294  ( 295,1,"Trofeo Joan Gamper","soccer","esp.joan_gamper"),
5295  ( 296,1,"German DFL-Supercup","soccer","ger.super_cup"),
5296  ( 297,1,"Audi Cup","soccer","ger.audi_cup"),
5297  ( 298,1,"Premier League Asia Trophy","soccer","eng.asia_trophy"),
5298  ( 299,1,"Emirates Cup","soccer","friendly.emirates_cup"),
5299  ( 300,1,"Japanese J League World Challenge","soccer","jpn.world_challenge"),
5300  ( 301,1,"SuperCopa Euroamericana","soccer","euroamericana.supercopa"),
5301  ( 302,1,"Men's Olympic Tournament","soccer","fifa.olympics"),
5302  ( 303,1,"Women's Olympic Tournament","soccer","fifa.w.olympics"),
5303  ( 304,1,"CONMEBOL Pre-Olympic Tournament","soccer","fifa.conmebol.olympicsq"),
5304  ( 305,1,"CONCACAF Men's Olympic Qualifying","soccer","fifa.concacaf.olympicsq"),
5305  ( 306,1,"CONCACAF Women's Olympic Qualifying Tournament","soccer","fifa.w.concacaf.olympicsq"),
5306  ( 307,1,"CONCACAF Women's Championship","soccer","concacaf.womens.championship"),
5307  ( 308,1,"FIFA Under-20 World Cup","soccer","fifa.world.u20"),
5308  ( 309,1,"FIFA Under-17 World Cup","soccer","fifa.world.u17"),
5309  ( 310,1,"Toulon Tournament","soccer","global.toulon"),
5310  ( 311,1,"UEFA European Under-21 Championship","soccer","uefa.euro_u21"),
5311  ( 312,1,"UEFA European Under-19 Championship","soccer","uefa.euro.u19"),
5312  ( 313,1,"Under-21 International Friendly","soccer","fifa.friendly_u21"),
5313  ( 314,1,"UEFA Women's European Championship","soccer","uefa.weuro"),
5314  ( 315,1,"German Bundesliga Promotion/Relegation Playoff","soccer","ger.playoff.relegation"),
5315  ( 316,1,"German 2. Bundesliga Promotion/Relegation Playoffs","soccer","ger.2.promotion.relegation"),
5316  ( 317,1,"English Women's FA Cup","soccer","eng.w.fa"),
5317  ( 318,1,"English Women's FA Community Shield","soccer","eng.w.charity"),
5318  ( 319,1,"English EFL Trophy","soccer","eng.trophy"),
5319  ( 320,1,"English National League","soccer","eng.5"),
5320  ( 321,1,"English League One","soccer","eng.3"),
5321  ( 322,1,"English League Two","soccer","eng.4"),
5322  ( 323,1,"Scottish Cup","soccer","sco.tennents"),
5323  ( 324,1,"Scottish League Cup","soccer","sco.cis"),
5324  ( 325,1,"Scottish Premiership Promotion/Relegation Playoffs","soccer","sco.1.promotion.relegation"),
5325  ( 326,1,"Scottish League One","soccer","sco.3"),
5326  ( 327,1,"Scottish Championship","soccer","sco.2"),
5327  ( 328,1,"Scottish Championship Promotion/Relegation Playoffs","soccer","sco.2.promotion.relegation"),
5328  ( 329,1,"Scottish League One Promotion/Relegation Playoffs","soccer","sco.3.promotion.relegation"),
5329  ( 330,1,"Scottish League Two Promotion/Relegation Playoffs","soccer","sco.4.promotion.relegation"),
5330  ( 331,1,"Scottish League Two","soccer","sco.4"),
5331  ( 332,1,"Scottish League Challenge Cup","soccer","sco.challenge"),
5332  ( 333,1,"Dutch Eredivisie Promotion/Relegation Playoffs","soccer","ned.playoff.relegation"),
5333  ( 334,1,"Dutch Eredivisie Cup","soccer","ned.w.eredivisie_cup"),
5334  ( 335,1,"Dutch Keuken Kampioen Divisie","soccer","ned.2"),
5335  ( 336,1,"Dutch Tweede Divisie","soccer","ned.3"),
5336  ( 337,1,"Dutch KNVB Beker Vrouwen","soccer","ned.w.knvb_cup"),
5337  ( 338,1,"Dutch Vrouwen Eredivisie","soccer","ned.w.1"),
5338  ( 339,1,"Italian Serie B","soccer","ita.2"),
5339  ( 340,1,"French Ligue 1 Promotion/Relegation Playoffs","soccer","fra.1.promotion.relegation"),
5340  ( 341,1,"French Ligue 2 Promotion/Relegation Playoffs","soccer","fra.2.promotion.relegation"),
5341  ( 342,1,"Swedish Allsvenskan","soccer","swe.1"),
5342  ( 343,1,"Swedish Allsvenskanliga Promotion/Relegation Playoffs","soccer","swe.1.promotion.relegation"),
5343  ( 344,1,"Danish Superliga","soccer","den.1"),
5344  ( 345,1,"Danish SAS-Ligaen Promotion/Relegation Playoffs","soccer","den.promotion.relegation"),
5345  ( 346,1,"Romanian Liga 1 Promotion/Relegation Playoffs","soccer","rou.1.promotion.relegation"),
5346  ( 347,1,"Romanian Liga 1","soccer","rou.1"),
5347  ( 348,1,"Norwegian Eliteserien Promotion/Relegation Playoffs","soccer","nor.1.promotion.relegation"),
5348  ( 349,1,"Norwegian Eliteserien","soccer","nor.1"),
5349  ( 350,1,"Maltese Premier League","soccer","mlt.1"),
5350  ( 351,1,"Israeli Premier League","soccer","isr.1"),
5351  ( 352,1,"Irish Premier Division Promotion/Relegation Playoffs","soccer","ir1.1.promotion.relegation"),
5352  ( 353,1,"Irish Premier Division","soccer","irl.1"),
5353  ( 354,1,"Welsh Premier League","soccer","wal.1"),
5354  ( 355,1,"Northern Irish Premiership","soccer","nir.1"),
5355  ( 356,1,"CONMEBOL Copa Libertadores","soccer","conmebol.libertadores"),
5356  ( 357,1,"CONMEBOL Copa Sudamericana","soccer","conmebol.sudamericana"),
5357  ( 358,1,"CONMEBOL Recopa Sudamericana","soccer","conmebol.recopa"),
5358  ( 359,1,"Argentine Liga Profesional de Fútbol","soccer","arg.1"),
5359  ( 360,1,"Copa Argentina","soccer","arg.copa"),
5360  ( 361,1,"Argentine Copa de la Liga Profesional","soccer","arg.copa_lpf"),
5361  ( 362,1,"Argentine Copa de la Superliga","soccer","arg.copa_de_la_superliga"),
5362  ( 363,1,"Argentine Trofeo de Campeones de la Superliga","soccer","arg.trofeo_de_la_campeones"),
5363  ( 364,1,"Argentine Supercopa","soccer","arg.supercopa"),
5364  ( 365,1,"Argentine Nacional B","soccer","arg.2"),
5365  ( 366,1,"Argentine Primera B","soccer","arg.3"),
5366  ( 367,1,"Argentine Primera C","soccer","arg.4"),
5367  ( 368,1,"Argentine Primera D","soccer","arg.5"),
5368  ( 369,1,"Supercopa Do Brazil","soccer","bra.supercopa_do_brazil"),
5369  ( 370,1,"Brazilian Serie A","soccer","bra.1"),
5370  ( 371,1,"Brazilian Serie B","soccer","bra.2"),
5371  ( 372,1,"Brazilian Serie C","soccer","bra.3"),
5372  ( 373,1,"Copa Do Nordeste","soccer","bra.copa_do_nordeste"),
5373  ( 374,1,"Brazilian Campeonato Carioca","soccer","bra.camp.carioca"),
5374  ( 375,1,"Brazilian Campeonato Paulista","soccer","bra.camp.paulista"),
5375  ( 376,1,"Brazilian Campeonato Gaucho","soccer","bra.camp.gaucho"),
5376  ( 377,1,"Brazilian Campeonato Mineiro","soccer","bra.camp.mineiro"),
5377  ( 378,1,"Chilean Primera División","soccer","chi.1"),
5378  ( 379,1,"Copa Chile","soccer","chi.copa_chi"),
5379  ( 380,1,"International U20 Friendly","soccer","fifa.u20.friendly"),
5380  ( 381,1,"Segunda División de Chile","soccer","chi.2"),
5381  ( 382,1,"Chilean Supercopa","soccer","chi.super_cup"),
5382  ( 383,1,"Uruguayan Primera Division","soccer","uru.1"),
5383  ( 384,1,"Segunda División de Uruguay","soccer","uru.2"),
5384  ( 385,1,"Colombian SuperLiga","soccer","col.superliga"),
5385  ( 386,1,"Colombian Primera A","soccer","col.1"),
5386  ( 387,1,"Colombian Primera B","soccer","col.2"),
5387  ( 388,1,"Peruvian Supercopa","soccer","per.supercopa"),
5388  ( 389,1,"Copa Colombia","soccer","col.copa"),
5389  ( 390,1,"Peruvian Primera Profesional","soccer","per.1"),
5390  ( 391,1,"Paraguayan Primera Division","soccer","par.1"),
5391  ( 392,1,"Ecuadoran Primera A","soccer","ecu.1"),
5392  ( 393,1,"Ecuadoran Supercopa","soccer","ecu.supercopa"),
5393  ( 394,1,"Ecuador Serie B","soccer","ecu.2"),
5394  ( 395,1,"Venezuelan Primera Profesional","soccer","ven.1"),
5395  ( 396,1,"United States NWSL Challenge Cup","soccer","usa.nwsl.cup"),
5396  ( 397,1,"Segunda División de Venezuela","soccer","ven.2"),
5397  ( 398,1,"Bolivian Liga Profesional","soccer","bol.1"),
5398  ( 399,1,"Mexican Supercopa MX","soccer","mex.supercopa"),
5399  ( 400,1,"Mexican Campeon de Campeones","soccer","mex.campeon"),
5400  ( 401,1,"CONCACAF Champions Cup","soccer","concacaf.champions_cup"),
5401  ( 402,1,"CONCACAF U23 Tournament","soccer","concacaf.u23"),
5402  ( 403,1,"Honduran Primera Division","soccer","hon.1"),
5403  ( 404,1,"Costa Rican Primera Division","soccer","crc.1"),
5404  ( 405,1,"Jamaican Premier League","soccer","jam.1"),
5405  ( 406,1,"Guatemalan Liga Nacional","soccer","gua.1"),
5406  ( 407,1,"Australian W-League","soccer","aus.w.1"),
5407  ( 408,1,"Salvadoran Primera Division","soccer","slv.1"),
5408  ( 409,1,"AFF Cup","soccer","aff.championship"),
5409  ( 410,1,"AFC Cup","soccer","afc.cup"),
5410  ( 411,1,"SAFF Championship","soccer","afc.saff.championship"),
5411  ( 412,1,"Chinese Super League Promotion/Relegation Playoffs","soccer","chn.1.promotion.relegation"),
5412  ( 413,1,"Japanese J League","soccer","jpn.1"),
5413  ( 414,1,"Indonesian Liga 1","soccer","idn.1"),
5414  ( 415,1,"Indian Super League","soccer","ind.1"),
5415  ( 416,1,"Indian I-League","soccer","ind.2"),
5416  ( 417,1,"Malaysian Super League","soccer","mys.1"),
5417  ( 418,1,"Singaporean Premier League","soccer","sgp.1"),
5418  ( 419,1,"Thai League 1","soccer","tha.1"),
5419  ( 420,1,"Bangabandhu Cup","soccer","bangabandhu.cup"),
5420  ( 421,1,"COSAFA Cup","soccer","caf.cosafa"),
5421  ( 422,1,"CAF Champions League","soccer","caf.champions"),
5422  ( 423,1,"South African Premiership Promotion/Relegation Playoffs","soccer","rsa.1.promotion.relegation"),
5423  ( 424,1,"CAF Confederations Cup","soccer","caf.confed"),
5424  ( 425,1,"South African Premiership","soccer","rsa.1"),
5425  ( 426,1,"South African First Division","soccer","rsa.2"),
5426  ( 427,1,"South African Telkom Knockout","soccer","rsa.telkom_knockout"),
5427  ( 428,1,"South African Nedbank Cup","soccer","rsa.nedbank"),
5428  ( 429,1,"MTN 8 Cup","soccer","rsa.mtn8"),
5429  ( 430,1,"Nigerian Professional League","soccer","nga.1"),
5430  ( 431,1,"Ghanaian Premier League","soccer","gha.1"),
5431  ( 432,1,"Zambian Super League","soccer","zam.1"),
5432  ( 433,1,"Kenyan Premier League","soccer","ken.1"),
5433  ( 434,1,"Zimbabwean Premier Soccer League","soccer","zim.1"),
5434  ( 435,1,"Ugandan Premier League","soccer","uga.1"),
5435  ( 436,1,"Misc. U.S. Soccer Games","soccer","generic.ussf");)",
5436 
5437  R"(INSERT INTO sportsapi
5438  VALUES
5439  (1000,2,"Major League Baseball","baseball","mlb");)",
5440 
5441  R"(CREATE TABLE sportslisting (
5442  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
5443  api INT UNSIGNED NOT NULL,
5444  title VARCHAR(128) NOT NULL
5445  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;)",
5446 
5447  R"(INSERT INTO sportslisting (api,title)
5448  VALUES
5449  ( 1, "\\A(?:MLB Baseball)\\z"),
5450  ( 1, "\\A(?:Béisbol MLB)\\z"),
5451  ( 1, "\\A(?:MLB All-Star Game)\\z"),
5452  ( 1, "\\A(?:World Series)\\z"),
5453  ( 2, "\\A(?:College Baseball)\\z"),
5454  ( 2, "\\A(?:College World Series)\\z"),
5455  ( 3, "\\A(?:College Softball)\\z"),
5456  ( 4, "\\A(?:Women's College World Series)\\z"),
5457  ( 10, "\\A(?:Béisbol Liga Mexicana)\\z"),
5458 
5459  ( 20, "\\A(?:N\\w+ Football)\\z"),
5460  ( 20, "\\A(?:Super Bowl( [CLXVI]+)?)\\z"),
5461  ( 20, "\\A(?:Fútbol Americano NFL)\\z"),
5462  ( 21, "\\A(?:College Football)\\z"),
5463  ( 21, "\\A(?:\\w+ Bowl)\\z"),
5464  ( 21, "\\A(?:Fútbol Americano de Universitario)\\z"),
5465 
5466  ( 40, "\\A(?:NBA Basketball)\\z"),
5467  ( 40, "\\A(?:NBA Finals)\\z"),
5468  ( 41, "\\A(?:WNBA Basketball)\\z"),
5469  ( 41, "\\A(?:WNBA Finals)\\z"),
5470  ( 42, "\\A(?:College Basketball)\\z"),
5471  ( 42, "\\A(?:NCAA Basketball Tournament)\\z"),
5472  ( 43, "\\A(?:Women's College Basketball)\\z"),
5473  ( 43, "\\A(?:NCAA Women's Basketball Tournament)\\z"),
5474 
5475  ( 60, "\\A(?:NHL Hockey)\\z"),
5476  ( 60, "\\A(?:NHL Winter Classic)\\z"),
5477  ( 60, "\\A(?:NHL \\w+ Conference Final)\\z"),
5478  ( 60, "\\A(?:Stanley Cup Finals)\\z"),
5479  ( 61, "\\A(?:College Hockey)\\z"),
5480  ( 61, "\\A(?:Frozen Four)\\z"),
5481  ( 62, "\\A(?:Women's College Hockey)\\z"),
5482  ( 66, "\\A(?:College Field Hockey)\\z"),
5483 
5484  ( 80, "\\A(?:College Volleyball)\\z"),
5485  ( 81, "\\A(?:Women's College Volleyball)\\z"),
5486 
5487  ( 100, "\\A(?:College Lacrosse)\\z"),
5488  ( 101, "\\A(?:Women's College Lacrosse)\\z"),
5489 
5490  ( 120, "\\A(?:College Water Polo)\\z"),
5491  ( 121, "\\A(?:Women's College Water Polo)\\z"),
5492 
5493  ( 200, "\\A(?:College Soccer)\\z"),
5494  ( 201, "\\A(?:Women's College Soccer)\\z"),
5495  ( 202, "\\A(?:MLS Soccer|Fútbol MLS)\\z"),
5496  ( 203, "\\A(?:(Premier League|EPL) Soccer)\\z"),
5497  ( 203, "\\A(?:English Premier League)\\z"),
5498  ( 203, "\\A(?:Fútbol Premier League)\\z"),
5499  ( 205, "\\A(?:Italian Serie A Soccer)\\z"),
5500  ( 339, "\\A(?:Italian Serie B Soccer)\\z"),
5501  ( 206, "\\A(?:French Ligue 1 Soccer|Fútbol Ligue 1|Fútbol Liga 1)\\z"),
5502  ( 207, "\\A(?:French Ligue 2 Soccer|Fútbol Ligue 2|Fútbol Liga 2)\\z"),
5503  ( 208, "\\A(?:Fútbol LaLiga)\\z"),
5504  ( 208, "\\A(?:Fútbol Español Primera Division)\\z"),
5505  ( 208, "\\A(?:Spanish Primera Division Soccer)\\z"),
5506  ( 209, "\\A(?:(German )?Bundesliga Soccer)\\z"),
5507  ( 209, "\\A(?:Fútbol Bundesliga)\\z"),
5508  ( 209, "\\A(?:Fútbol Copa de Alemania)\\z"),
5509  ( 210, "\\A(?:German 2. Bundesliga Soccer)\\z"),
5510  ( 211, "\\A(?:Fútbol Mexicano Primera División|Fútbol Mexicano Liga Premier|Fútbol Mexicano)\\z"),
5511  ( 211, "\\A(?:Mexico Primera Division Soccer)\\z"),
5512  ( 212, "\\A(?:Copa do Brazil Soccer)\\z"),
5513  ( 214, "\\A(?:CONCACAF League Soccer)\\z"),
5514  ( 215, "\\A(?:CONCACAF Champions League Soccer)\\z"),
5515  ( 216, "\\A(?:CONCACAF Nations League Soccer)\\z"),
5516  ( 217, "\\A(?:CONCACAF Gold Cup Soccer)\\z"),
5517  ( 218, "\\A(?:FIFA World Cup Soccer)\\z"),
5518  ( 219, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5519  ( 220, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5520  ( 221, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5521  ( 222, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5522  ( 223, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5523  ( 224, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5524  ( 225, "\\A(?:Fútbol UEFA Champions League)\\z"),
5525  ( 225, "\\A(?:UEFA Champions League Soccer)\\z"),
5526  ( 226, "\\A(?:Fútbol UEFA Europa League)\\z"),
5527  ( 229, "\\A(?:Fútbol USL Championship)\\z"),
5528  ( 229, "\\A(?:USL Championship Soccer)\\z"),
5529  ( 230, "\\A(?:NWSL Soccer)\\z"),
5530  ( 231, "\\A(?:FA Women's Super League)\\z"),
5531  ( 242, "\\A(?:Fútbol Mexicano Liga Expansión)\\z"),
5532  ( 258, "\\A(?:UEFA Nations League Soccer)\\z"),
5533  ( 258, "\\A(?:Fútbol UEFA Nations League)\\z"),
5534  ( 271, "\\A(?:Fútbol Español Segunda Division)\\z"),
5535  ( 277, "\\A(?:Fútbol Turco Superliga)\\z"),
5536  ( 277, "\\A(?:Turkish Super Lig Soccer)\\z"),
5537  ( 279, "\\A(?:Superleague Greek Soccer)\\z"),
5538  ( 356, "\\A(?:Fútbol CONMEBOL Libertadores)\\z"),
5539  ( 357, "\\A(?:Fútbol CONMEBOL Sudamericana)\\z"),
5540  ( 359, "\\A(?:Fútbol Argentino Primera División)\\z"),
5541  ( 360, "\\A(?:Fútbol Copa Argentina)\\z"),
5542  ( 365, "\\A(?:Fútbol Argentino Primera Nacional( B)?)\\z"),
5543  ( 366, "\\A(?:Fútbol Argentino Primera B)\\z"),
5544  ( 367, "\\A(?:Fútbol Argentino Primera C)\\z"),
5545  ( 368, "\\A(?:Fútbol Argentino Primera D)\\z"),
5546  ( 386, "\\A(?:Fútbol Columbiano Primera División)\\z"),
5547  ( 403, "\\A(?:Fútbol Hondureño Primera División)\\z"),
5548  ( 404, "\\A(?:Fútbol Costarricense Primera División)\\z"),
5549 
5550  (1000, "\\A(?:MLB Baseball)\\z"),
5551  (1000, "\\A(?:Béisbol MLB)\\z");
5552  )",
5553 
5554  R"(CREATE TABLE sportscleanup (
5555  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
5556  provider TINYINT UNSIGNED DEFAULT 0,
5557  weight INT UNSIGNED NOT NULL,
5558  key1 VARCHAR(256) NOT NULL,
5559  name VARCHAR(256) NOT NULL,
5560  pattern VARCHAR(256) NOT NULL,
5561  nth TINYINT UNSIGNED NOT NULL,
5562  replacement VARCHAR(128) NOT NULL
5563  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;)",
5564 
5565  // Sigh. It would be nice if these patterns could use the
5566  // '\b' boundary matching sequence in the first part of
5567  // the match, but the period is not part of the set of
5568  // characters that make up a word, so trying to optionally
5569  // match the final period in the string "F.C. Foo" with
5570  // the pattern "\.?\b" always fails because period and
5571  // space are both non-word characters and therefore there
5572  // is no word boundary between them. This will always
5573  // match on "F.C" and never on "F.C.".
5574  //
5575  // I have also seen a TV listing where the team name was
5576  // "F.C.Something" without a space, so the first part of
5577  // these patterns doesn't require a following space in
5578  // order to match. These patterns are case sensitive, so
5579  // the first part shouldn't match part of an ordinary team
5580  // name unless the team name is in all caps.
5581  R"A(INSERT INTO sportscleanup (provider,weight,key1,name,pattern,nth,replacement)
5582  VALUES
5583  (1,1000,"soccer", "(SE)", "\\(\\w+\\)", 0, ""),
5584  (1,1000,"soccer", "AFC", "\\AA\\.?F\\.?C\\.?|\\bA\\.?F\\.?C\\.?\\Z", 0, ""),
5585  (1,1000,"soccer", "AC etc.", "\\AA\\.?[AC]\\.?|\\bA\\.?[AC]\\.?\\Z", 0, ""),
5586  (1,1000,"soccer", "BK", "\\AB\\.?K\\.?|\\bB\\.?K\\.?\\Z", 0, ""),
5587  (1,1000,"soccer", "BSC", "\\AB\\.?S\\.?C\\.?|\\bB\\.?S\\.?C\\.?\\Z", 0, ""),
5588  (1,1000,"soccer", "CSyD", "\\AC\\.?S\\.?( y )?D\\.?|\\bC\\.?S\\.?( y )?D\\.?\\Z", 0, ""),
5589  (1,1000,"soccer", "CD etc.", "\\AC\\.?[ADFRS]\\.?|\\bC\\.?[ADFRS]\\.?\\Z", 0, ""),
5590  (1,1000,"soccer", "FC", "\\AF\\.?C\\.?|\\bF\\.?C\\.?\\Z", 0, ""),
5591  (1,1000,"soccer", "HSC", "\\AH\\.?S\\.?C\\.?|\\bH\\.?S\\.?C\\.?\\Z", 0, ""),
5592  (1,1000,"soccer", "RC etc.", "\\AR\\.?[BC]\\.?|\\bR\\.?[BC]\\.?\\Z", 0, ""),
5593  (1,1000,"soccer", "SC etc.", "\\AS\\.?[ACV]\\.?|\\bS\\.?[ACV]\\.?\\Z", 0, ""),
5594  (1,1000,"soccer", "TSG", "\\AT\\.?S\\.?G\\.?|\\bT\\.?S\\.?G\\.?\\Z", 0, ""),
5595  (1,1000,"soccer", "VFB etc.", "\\AV\\.?F\\.?[BL]\\.?|\\bV\\.?F\\.?[BL]\\.?\\Z", 0, ""),
5596  (1,2000,"all", "", "Inglaterra", 0, "England"),
5597  (1,2000,"all", "", "Munchen", 0, "Munich");
5598  )A",
5599  };
5600  case 2:
5601  return {
5602  // More TV listing name to API name mappings for college
5603  // basketball. Using a weight of 1000 for specific
5604  // changes and 1100 for general changes.
5605  R"A(INSERT INTO sportscleanup (provider,weight,key1,name,pattern,nth,replacement)
5606  VALUES
5607  (1,1100,"basketball", "Cal State", "Cal State", 0, "CSU"),
5608  (1,1000,"basketball", "Grambling", "Grambling State", 0, "Grambling"),
5609  (1,1000,"basketball", "Hawaii", "Hawaii", 0, "Hawai'i"),
5610  (1,1000,"basketball", "LIU", "LIU", 0, "Long Island University"),
5611  (1,1100,"basketball", "Loyola", "Loyola-", 0, "Loyola "),
5612  (1,1000,"basketball", "Loyola (Md.)", "Loyola \(Md.\)", 0, "Loyola (MD)"),
5613  (1,1000,"basketball", "McNeese", "McNeese State", 0, "McNeese"),
5614  (1,1000,"basketball", "Miami (OH)", "Miami \(Ohio\)", 0, "Miami (OH)"),
5615  (1,1000,"basketball", "UAB", "Alabama-Birmingham", 0, "UAB"),
5616  (1,1000,"basketball", "UConn", "Connecticut", 0, "UConn"),
5617  (1,1000,"basketball", "UMass", "Massachusetts", 0, "UMass"),
5618  (1,1100,"basketball", "UNC", "UNC-", 0, "UNC "),
5619  (1,1000,"basketball", "UTEP", "Texas-El Paso", 0, "UTEP"),
5620  (1,1100,"basketball", "Texas", "Texas-", 0, "UT "),
5621  (1,1000,"basketball", "Chattanooga", "UT-Chattanooga", 0, "Chattanooga"),
5622  (1,1100,"basketball", "UT", "UT-", 0, "UT ");
5623  )A",
5624  };
5625 
5626  default:
5627  return {};
5628  }
5629 }
5630 
5631 /* vim: set expandtab tabstop=4 shiftwidth=4: */
5632 
MSqlQuery::isActive
bool isActive(void) const
Definition: mythdbcon.h:216
MSqlQuery::next
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:811
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:128
RecordingRule::m_autoTranscode
bool m_autoTranscode
Definition: recordingrule.h:132
MSqlQuery::size
int size(void) const
Definition: mythdbcon.h:215
MYTH_SCHEMA_ERROR
@ MYTH_SCHEMA_ERROR
Definition: schemawizard.h:17
MARK_ASPECT_16_9
@ MARK_ASPECT_16_9
Definition: programtypes.h:67
dbutil.h
MARK_ASPECT_2_21_1
@ MARK_ASPECT_2_21_1
Definition: programtypes.h:68
RecordingRule::m_autoCommFlag
bool m_autoCommFlag
Definition: recordingrule.h:131
SchemaUpgradeWizard::Get
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...
Definition: schemawizard.cpp:54
mythdb.h
MythVideoProfileItem
Definition: mythvideoprofile.h:55
RecordingRule::Save
bool Save(bool sendSig=true)
Definition: recordingrule.cpp:388
RecordingRule::GetDefaultFilter
static unsigned GetDefaultFilter(void)
Definition: recordingrule.cpp:783
DEINT_QUALITY_MEDIUM
static constexpr const char * DEINT_QUALITY_MEDIUM
Definition: mythvideoprofile.h:23
MYTH_SCHEMA_UPGRADE
@ MYTH_SCHEMA_UPGRADE
Definition: schemawizard.h:18
RecordingInfo
Holds information on a TV Program one might wish to record.
Definition: recordinginfo.h:35
SchemaUpgradeWizard::Compare
int Compare(void)
How many schema versions old is the DB?
Definition: schemawizard.cpp:100
MSqlQuery::lastInsertId
QVariant lastInsertId()
Return the id of the last inserted row.
Definition: mythdbcon.cpp:934
DEINT_QUALITY_HIGH
static constexpr const char * DEINT_QUALITY_HIGH
Definition: mythvideoprofile.h:24
MSqlQuery::value
QVariant value(int i) const
Definition: mythdbcon.h:205
RecordingRule
Internal representation of a recording rule, mirrors the record table.
Definition: recordingrule.h:28
RecordingDupMethodType
RecordingDupMethodType
Definition: recordingtypes.h:62
RecordingRule::m_endOffset
int m_endOffset
Definition: recordingrule.h:110
MSqlQuery::exec
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:617
SchemaUpgradeWizard::PromptForUpgrade
enum MythSchemaUpgrade PromptForUpgrade(const char *name, bool upgradeAllowed, bool upgradeIfNoUI, int minDBMSmajor=0, int minDBMSminor=0, int minDBMSpoint=0)
Query user, to prevent silent, automatic database upgrades.
Definition: schemawizard.cpp:224
RecordingFile
Holds information on a recording file and it's video and audio streams.
Definition: recordingfile.h:29
videodbcheck.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
GetMythDB
MythDB * GetMythDB(void)
Definition: mythdb.cpp:50
db_sd_notify
static void db_sd_notify(const char *)
Definition: dbcheck.cpp:40
MYTH_SCHEMA_USE_EXISTING
@ MYTH_SCHEMA_USE_EXISTING
Definition: schemawizard.h:19
RecordingRule::m_startOffset
int m_startOffset
Definition: recordingrule.h:109
InitializeMythSchema
bool InitializeMythSchema(void)
command to get the the initial database layout from an empty database:
Definition: dbcheck.cpp:3982
Decoder
Definition: decoder.h:70
CardUtil::UnlinkInputGroup
static bool UnlinkInputGroup(uint inputid, uint inputgroupid)
Definition: cardutil.cpp:2152
MythVideoProfileItem::SetProfileID
void SetProfileID(uint Id)
Definition: mythvideoprofile.cpp:23
mythlogging.h
RecordingFile::m_videoResolution
QSize m_videoResolution
Definition: recordingfile.h:50
MYTH_SCHEMA_EXIT
@ MYTH_SCHEMA_EXIT
Definition: schemawizard.h:16
hardwareprofile.scan.profile
profile
Definition: scan.py:99
RecordingRule::m_autoUserJob4
bool m_autoUserJob4
Definition: recordingrule.h:136
UpgradeTVDatabaseSchema
bool UpgradeTVDatabaseSchema(const bool upgradeAllowed, const bool upgradeIfNoUI, [[maybe_unused]] const bool informSystemd)
Called from outside dbcheck.cpp to update the schema.
Definition: dbcheck.cpp:361
dbcheck.h
kTemplateRecord
@ kTemplateRecord
Definition: recordingtypes.h:33
MSqlQuery::InitCon
static MSqlQueryInfo InitCon(ConnectionReuse _reuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:549
compat.h
RecordingRule::m_autoUserJob2
bool m_autoUserJob2
Definition: recordingrule.h:134
RecordingFile::Save
bool Save()
Definition: recordingfile.cpp:55
MythDB::DBError
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:226
RecordingRule::m_autoExpire
bool m_autoExpire
Definition: recordingrule.h:126
DEINT_QUALITY_DRIVER
static constexpr const char * DEINT_QUALITY_DRIVER
Definition: mythvideoprofile.h:26
mythdbcheck.h
RecordingRule::m_type
RecordingType m_type
Definition: recordingrule.h:111
RecordingProfile::kTranscoderAutodetect
static const uint kTranscoderAutodetect
sentinel value
Definition: recordingprofile.h:132
mythvideoprofile.h
RecordingRule::m_filter
unsigned m_filter
Definition: recordingrule.h:115
uint
unsigned int uint
Definition: compat.h:81
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
DBUtil::TryLockSchema
static bool TryLockSchema(MSqlQuery &query, uint timeout_secs)
Try to get a lock on the table schemalock.
Definition: dbutil.cpp:848
RecordingRule::MakeTemplate
bool MakeTemplate(QString category)
Definition: recordingrule.cpp:317
RecordingFile::m_videoFrameRate
double m_videoFrameRate
Definition: recordingfile.h:52
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:911
DEINT_QUALITY_LOW
static constexpr const char * DEINT_QUALITY_LOW
Definition: mythvideoprofile.h:22
MythVideoProfileItem::Set
void Set(const QString &Value, const QString &Data)
Definition: mythvideoprofile.cpp:28
performUpdateSeries
bool performUpdateSeries(const QString &component, const DBUpdates &updates)
Definition: dbcheckcommon.cpp:80
MARK_ASPECT_4_3
@ MARK_ASPECT_4_3
Definition: programtypes.h:66
RecordingFile::m_fileSize
uint64_t m_fileSize
Definition: recordingfile.h:45
UpdateDBVersionNumber
bool UpdateDBVersionNumber(const QString &component, const QString &versionkey, const QString &newnumber, QString &dbver)
Updates the schema version stored in the database.
Definition: dbcheckcommon.cpp:28
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:905
MINIMUM_DBMS_VERSION
#define MINIMUM_DBMS_VERSION
Definition: dbcheck.cpp:27
MythVideoProfileItem::Clear
void Clear()
Definition: mythvideoprofile.cpp:18
recordinginfo.h
DEINT_QUALITY_SHADER
static constexpr const char * DEINT_QUALITY_SHADER
Definition: mythvideoprofile.h:25
RecordingRule::m_transcoder
int m_transcoder
Definition: recordingrule.h:130
RecordingRule::m_autoUserJob1
bool m_autoUserJob1
Definition: recordingrule.h:133
MARK_ASPECT_1_1
@ MARK_ASPECT_1_1
deprecated, it is only 1:1 sample aspect ratio
Definition: programtypes.h:65
performActualUpdate
bool performActualUpdate(const QString &component, const QString &versionkey, const DBUpdates &updates, const QString &version, QString &dbver)
Definition: dbcheckcommon.cpp:113
mythcorecontext.h
cardutil.h
schemawizard.h
RecordingRule::m_dupMethod
RecordingDupMethodType m_dupMethod
Definition: recordingrule.h:113
SchemaUpgradeWizard
Provides UI and helper functions for DB Schema updates.
Definition: schemawizard.h:25
doUpgradeTVDatabaseSchema
static bool doUpgradeTVDatabaseSchema(void)
This is called by UpgradeTVDatabaseSchema() to actually upgrade the schema to what MythTV expects.
Definition: dbcheck.cpp:468
MSqlQuery::bindValue
void bindValue(const QString &placeholder, const QVariant &val)
Add a single binding.
Definition: mythdbcon.cpp:887
RecordingFile::m_fileName
QString m_fileName
Definition: recordingfile.h:44
doUpgradeVideoDatabaseSchema
bool doUpgradeVideoDatabaseSchema(void)
Definition: videodbcheck.cpp:287
DBUtil::IsNewDatabase
static bool IsNewDatabase(void)
Returns true for a new (empty) database.
Definition: dbutil.cpp:78
build_compdb.action
action
Definition: build_compdb.py:9
MythCoreContext::ActivateSettingsCache
void ActivateSettingsCache(bool activate=true)
Definition: mythcorecontext.cpp:832
DBUtil::UnlockSchema
static void UnlockSchema(MSqlQuery &query)
Definition: dbutil.cpp:855
RecordingFile::m_videoAspectRatio
double m_videoAspectRatio
Definition: recordingfile.h:51
currentDatabaseVersion
const QString currentDatabaseVersion
Definition: dbcheck.cpp:29
MythCoreContext::GetHostName
QString GetHostName(void)
Definition: mythcorecontext.cpp:837
recordingprofile.h
getRecordingExtenderDbInfo
MTV_PUBLIC DBUpdates getRecordingExtenderDbInfo(int version)
MythCoreContext::IsMasterHost
bool IsMasterHost(void)
is this the same host as the master
Definition: mythcorecontext.cpp:658
musicbrainzngs.caa.hostname
string hostname
Definition: caa.py:17
DBUpdates
std::vector< std::string > DBUpdates
Definition: mythdbcheck.h:9
recordingrule.h
RecordingFile::m_storageGroup
QString m_storageGroup
Definition: recordingfile.h:41
RecordingRule::m_autoUserJob3
bool m_autoUserJob3
Definition: recordingrule.h:135
MythCoreContext::SaveSettingOnHost
bool SaveSettingOnHost(const QString &key, const QString &newValue, const QString &host)
Definition: mythcorecontext.cpp:890
CardUtil::CreateInputGroup
static uint CreateInputGroup(const QString &name)
Definition: cardutil.cpp:2022
kDupCheckSubDesc
@ kDupCheckSubDesc
Definition: recordingtypes.h:68
CardUtil::LinkInputGroup
static bool LinkInputGroup(uint inputid, uint inputgroupid)
Definition: cardutil.cpp:2101
RecordingRule::m_autoMetadataLookup
bool m_autoMetadataLookup
Definition: recordingrule.h:137
RecordingFile::m_storageDeviceID
QString m_storageDeviceID
Definition: recordingfile.h:40
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:897
MSqlQuery::prepare
bool prepare(const QString &query)
QSqlQuery::prepare() is not thread safe in Qt <= 3.3.2.
Definition: mythdbcon.cpp:836