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