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  return true;
3935 }
3936 
3956 {
3957  MSqlQuery query(MSqlQuery::InitCon());
3958  query.prepare("SHOW TABLES;");
3959 
3960  // check for > 1 table here since the schemalock table should exist
3961  if (query.exec() && query.isActive() && query.size() > 1)
3962  {
3963  QString msg = QString(
3964  "Told to create a NEW database schema, but the database\n"
3965  "already has %1 tables.\n"
3966  "If you are sure this is a good MythTV database, verify\n"
3967  "that the settings table has the DBSchemaVer variable.\n")
3968  .arg(query.size() - 1);
3969  LOG(VB_GENERAL, LOG_ERR, msg);
3970  return false;
3971  }
3972 
3973  LOG(VB_GENERAL, LOG_NOTICE,
3974  "Inserting MythTV initial database information.");
3975 
3976  DBUpdates updates {
3977 "CREATE TABLE capturecard ("
3978 " cardid int(10) unsigned NOT NULL AUTO_INCREMENT,"
3979 " videodevice varchar(128) DEFAULT NULL,"
3980 " audiodevice varchar(128) DEFAULT NULL,"
3981 " vbidevice varchar(128) DEFAULT NULL,"
3982 " cardtype varchar(32) DEFAULT 'V4L',"
3983 " defaultinput varchar(32) DEFAULT 'Television',"
3984 " audioratelimit int(11) DEFAULT NULL,"
3985 " hostname varchar(64) DEFAULT NULL,"
3986 " dvb_swfilter int(11) DEFAULT '0',"
3987 " dvb_sat_type int(11) NOT NULL DEFAULT '0',"
3988 " dvb_wait_for_seqstart int(11) NOT NULL DEFAULT '1',"
3989 " skipbtaudio tinyint(1) DEFAULT '0',"
3990 " dvb_on_demand tinyint(4) NOT NULL DEFAULT '0',"
3991 " dvb_diseqc_type smallint(6) DEFAULT NULL,"
3992 " firewire_speed int(10) unsigned NOT NULL DEFAULT '0',"
3993 " firewire_model varchar(32) DEFAULT NULL,"
3994 " firewire_connection int(10) unsigned NOT NULL DEFAULT '0',"
3995 " signal_timeout int(11) NOT NULL DEFAULT '1000',"
3996 " channel_timeout int(11) NOT NULL DEFAULT '3000',"
3997 " dvb_tuning_delay int(10) unsigned NOT NULL DEFAULT '0',"
3998 " contrast int(11) NOT NULL DEFAULT '0',"
3999 " brightness int(11) NOT NULL DEFAULT '0',"
4000 " colour int(11) NOT NULL DEFAULT '0',"
4001 " hue int(11) NOT NULL DEFAULT '0',"
4002 " diseqcid int(10) unsigned DEFAULT NULL,"
4003 " dvb_eitscan tinyint(1) NOT NULL DEFAULT '1',"
4004 " PRIMARY KEY (cardid)"
4005 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4006 "CREATE TABLE cardinput ("
4007 " cardinputid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4008 " cardid int(10) unsigned NOT NULL DEFAULT '0',"
4009 " sourceid int(10) unsigned NOT NULL DEFAULT '0',"
4010 " inputname varchar(32) NOT NULL DEFAULT '',"
4011 " externalcommand varchar(128) DEFAULT NULL,"
4012 " changer_device varchar(128) DEFAULT NULL,"
4013 " changer_model varchar(128) DEFAULT NULL,"
4014 " tunechan varchar(10) DEFAULT NULL,"
4015 " startchan varchar(10) DEFAULT NULL,"
4016 " displayname varchar(64) NOT NULL DEFAULT '',"
4017 " dishnet_eit tinyint(1) NOT NULL DEFAULT '0',"
4018 " recpriority int(11) NOT NULL DEFAULT '0',"
4019 " quicktune tinyint(4) NOT NULL DEFAULT '0',"
4020 " schedorder int(10) unsigned NOT NULL DEFAULT '0',"
4021 " livetvorder int(10) unsigned NOT NULL DEFAULT '0',"
4022 " PRIMARY KEY (cardinputid)"
4023 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4024 "CREATE TABLE channel ("
4025 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4026 " channum varchar(10) NOT NULL DEFAULT '',"
4027 " freqid varchar(10) DEFAULT NULL,"
4028 " sourceid int(10) unsigned DEFAULT NULL,"
4029 " callsign varchar(20) NOT NULL DEFAULT '',"
4030 " `name` varchar(64) NOT NULL DEFAULT '',"
4031 " icon varchar(255) NOT NULL DEFAULT '',"
4032 " finetune int(11) DEFAULT NULL,"
4033 " videofilters varchar(255) NOT NULL DEFAULT '',"
4034 " xmltvid varchar(255) NOT NULL DEFAULT '',"
4035 " recpriority int(10) NOT NULL DEFAULT '0',"
4036 " contrast int(11) DEFAULT '32768',"
4037 " brightness int(11) DEFAULT '32768',"
4038 " colour int(11) DEFAULT '32768',"
4039 " hue int(11) DEFAULT '32768',"
4040 " tvformat varchar(10) NOT NULL DEFAULT 'Default',"
4041 " visible tinyint(1) NOT NULL DEFAULT '1',"
4042 " outputfilters varchar(255) NOT NULL DEFAULT '',"
4043 " useonairguide tinyint(1) DEFAULT '0',"
4044 " mplexid smallint(6) DEFAULT NULL,"
4045 " serviceid mediumint(8) unsigned DEFAULT NULL,"
4046 " tmoffset int(11) NOT NULL DEFAULT '0',"
4047 " atsc_major_chan int(10) unsigned NOT NULL DEFAULT '0',"
4048 " atsc_minor_chan int(10) unsigned NOT NULL DEFAULT '0',"
4049 " last_record datetime NOT NULL,"
4050 " default_authority varchar(32) NOT NULL DEFAULT '',"
4051 " commmethod int(11) NOT NULL DEFAULT '-1',"
4052 " iptvid smallint(6) unsigned DEFAULT NULL,"
4053 " PRIMARY KEY (chanid),"
4054 " KEY channel_src (channum,sourceid),"
4055 " KEY sourceid (sourceid,xmltvid,chanid),"
4056 " KEY visible (visible)"
4057 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4058 "CREATE TABLE channelgroup ("
4059 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4060 " chanid int(11) unsigned NOT NULL DEFAULT '0',"
4061 " grpid int(11) NOT NULL DEFAULT '1',"
4062 " PRIMARY KEY (id)"
4063 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4064 "CREATE TABLE channelgroupnames ("
4065 " grpid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4066 " `name` varchar(64) NOT NULL DEFAULT '0',"
4067 " PRIMARY KEY (grpid)"
4068 ") ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;",
4069 "CREATE TABLE channelscan ("
4070 " scanid int(3) unsigned NOT NULL AUTO_INCREMENT,"
4071 " cardid int(3) unsigned NOT NULL,"
4072 " sourceid int(3) unsigned NOT NULL,"
4073 " processed tinyint(1) unsigned NOT NULL,"
4074 " scandate datetime NOT NULL,"
4075 " PRIMARY KEY (scanid)"
4076 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4077 "CREATE TABLE channelscan_channel ("
4078 " transportid int(6) unsigned NOT NULL,"
4079 " scanid int(3) unsigned NOT NULL,"
4080 " mplex_id smallint(6) NOT NULL,"
4081 " source_id int(3) unsigned NOT NULL,"
4082 " channel_id int(3) unsigned NOT NULL DEFAULT '0',"
4083 " callsign varchar(20) NOT NULL DEFAULT '',"
4084 " service_name varchar(64) NOT NULL DEFAULT '',"
4085 " chan_num varchar(10) NOT NULL DEFAULT '',"
4086 " service_id mediumint(8) unsigned NOT NULL DEFAULT '0',"
4087 " atsc_major_channel int(4) unsigned NOT NULL DEFAULT '0',"
4088 " atsc_minor_channel int(4) unsigned NOT NULL DEFAULT '0',"
4089 " use_on_air_guide tinyint(1) NOT NULL DEFAULT '0',"
4090 " hidden tinyint(1) NOT NULL DEFAULT '0',"
4091 " hidden_in_guide tinyint(1) NOT NULL DEFAULT '0',"
4092 " freqid varchar(10) NOT NULL DEFAULT '',"
4093 " icon varchar(255) NOT NULL DEFAULT '',"
4094 " tvformat varchar(10) NOT NULL DEFAULT 'Default',"
4095 " xmltvid varchar(64) NOT NULL DEFAULT '',"
4096 " pat_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4097 " vct_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4098 " vct_chan_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4099 " sdt_tsid int(5) unsigned NOT NULL DEFAULT '0',"
4100 " orig_netid int(5) unsigned NOT NULL DEFAULT '0',"
4101 " netid int(5) unsigned NOT NULL DEFAULT '0',"
4102 " si_standard varchar(10) NOT NULL,"
4103 " in_channels_conf tinyint(1) unsigned NOT NULL DEFAULT '0',"
4104 " in_pat tinyint(1) unsigned NOT NULL DEFAULT '0',"
4105 " in_pmt tinyint(1) unsigned NOT NULL DEFAULT '0',"
4106 " in_vct tinyint(1) unsigned NOT NULL DEFAULT '0',"
4107 " in_nit tinyint(1) unsigned NOT NULL DEFAULT '0',"
4108 " in_sdt tinyint(1) unsigned NOT NULL DEFAULT '0',"
4109 " is_encrypted tinyint(1) unsigned NOT NULL DEFAULT '0',"
4110 " is_data_service tinyint(1) unsigned NOT NULL DEFAULT '0',"
4111 " is_audio_service tinyint(1) unsigned NOT NULL DEFAULT '0',"
4112 " is_opencable tinyint(1) unsigned NOT NULL DEFAULT '0',"
4113 " could_be_opencable tinyint(1) unsigned NOT NULL DEFAULT '0',"
4114 " decryption_status smallint(2) unsigned NOT NULL DEFAULT '0',"
4115 " default_authority varchar(32) NOT NULL DEFAULT ''"
4116 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4117 "CREATE TABLE channelscan_dtv_multiplex ("
4118 " transportid int(6) unsigned NOT NULL AUTO_INCREMENT,"
4119 " scanid int(3) unsigned NOT NULL,"
4120 " mplexid smallint(6) unsigned NOT NULL,"
4121 " frequency bigint(12) unsigned NOT NULL,"
4122 " inversion char(1) NOT NULL DEFAULT 'a',"
4123 " symbolrate bigint(12) unsigned NOT NULL DEFAULT '0',"
4124 " fec varchar(10) NOT NULL DEFAULT 'auto',"
4125 " polarity char(1) NOT NULL DEFAULT '',"
4126 " hp_code_rate varchar(10) NOT NULL DEFAULT 'auto',"
4127 " mod_sys varchar(10) DEFAULT NULL,"
4128 " rolloff varchar(4) DEFAULT NULL,"
4129 " lp_code_rate varchar(10) NOT NULL DEFAULT 'auto',"
4130 " modulation varchar(10) NOT NULL DEFAULT 'auto',"
4131 " transmission_mode char(1) NOT NULL DEFAULT 'a',"
4132 " guard_interval varchar(10) NOT NULL DEFAULT 'auto',"
4133 " hierarchy varchar(10) NOT NULL DEFAULT 'auto',"
4134 " bandwidth char(1) NOT NULL DEFAULT 'a',"
4135 " sistandard varchar(10) NOT NULL,"
4136 " tuner_type smallint(2) unsigned NOT NULL,"
4137 " default_authority varchar(32) NOT NULL DEFAULT '',"
4138 " PRIMARY KEY (transportid)"
4139 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4140 "CREATE TABLE codecparams ("
4141 " `profile` int(10) unsigned NOT NULL DEFAULT '0',"
4142 " `name` varchar(128) NOT NULL DEFAULT '',"
4143 " `value` varchar(128) DEFAULT NULL,"
4144 " PRIMARY KEY (`profile`,`name`)"
4145 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4146 "CREATE TABLE credits ("
4147 " person mediumint(8) unsigned NOT NULL DEFAULT '0',"
4148 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4149 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4150 " role set('actor','director','producer','executive_producer','writer','guest_star','host','adapter','presenter','commentator','guest') NOT NULL DEFAULT '',"
4151 " UNIQUE KEY chanid (chanid,starttime,person,role),"
4152 " KEY person (person,role)"
4153 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4154 "CREATE TABLE customexample ("
4155 " rulename varchar(64) NOT NULL,"
4156 " fromclause varchar(10000) NOT NULL DEFAULT '',"
4157 " whereclause varchar(10000) NOT NULL DEFAULT '',"
4158 " search tinyint(4) NOT NULL DEFAULT '0',"
4159 " PRIMARY KEY (rulename)"
4160 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4161 "CREATE TABLE diseqc_config ("
4162 " cardinputid int(10) unsigned NOT NULL,"
4163 " diseqcid int(10) unsigned NOT NULL,"
4164 " `value` varchar(16) NOT NULL DEFAULT '',"
4165 " KEY id (cardinputid)"
4166 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4167 "CREATE TABLE diseqc_tree ("
4168 " diseqcid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4169 " parentid int(10) unsigned DEFAULT NULL,"
4170 " ordinal tinyint(3) unsigned NOT NULL,"
4171 " `type` varchar(16) NOT NULL DEFAULT '',"
4172 " subtype varchar(16) NOT NULL DEFAULT '',"
4173 " description varchar(32) NOT NULL DEFAULT '',"
4174 " switch_ports tinyint(3) unsigned NOT NULL DEFAULT '0',"
4175 " rotor_hi_speed float NOT NULL DEFAULT '0',"
4176 " rotor_lo_speed float NOT NULL DEFAULT '0',"
4177 " rotor_positions varchar(255) NOT NULL DEFAULT '',"
4178 " lnb_lof_switch int(10) NOT NULL DEFAULT '0',"
4179 " lnb_lof_hi int(10) NOT NULL DEFAULT '0',"
4180 " lnb_lof_lo int(10) NOT NULL DEFAULT '0',"
4181 " cmd_repeat int(11) NOT NULL DEFAULT '1',"
4182 " lnb_pol_inv tinyint(4) NOT NULL DEFAULT '0',"
4183 " address tinyint(3) unsigned NOT NULL DEFAULT '0',"
4184 " PRIMARY KEY (diseqcid),"
4185 " KEY parentid (parentid)"
4186 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4187 "CREATE TABLE displayprofilegroups ("
4188 " `name` varchar(128) NOT NULL,"
4189 " hostname varchar(64) NOT NULL,"
4190 " profilegroupid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4191 " PRIMARY KEY (`name`,hostname),"
4192 " UNIQUE KEY profilegroupid (profilegroupid)"
4193 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4194 "CREATE TABLE displayprofiles ("
4195 " profilegroupid int(10) unsigned NOT NULL,"
4196 " profileid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4197 " `value` varchar(128) NOT NULL,"
4198 " `data` varchar(255) NOT NULL DEFAULT '',"
4199 " KEY profilegroupid (profilegroupid),"
4200 " KEY profileid (profileid,`value`),"
4201 " KEY profileid_2 (profileid)"
4202 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4203 "CREATE TABLE dtv_multiplex ("
4204 " mplexid smallint(6) NOT NULL AUTO_INCREMENT,"
4205 " sourceid smallint(6) DEFAULT NULL,"
4206 " transportid int(11) DEFAULT NULL,"
4207 " networkid int(11) DEFAULT NULL,"
4208 " frequency int(11) DEFAULT NULL,"
4209 " inversion char(1) DEFAULT 'a',"
4210 " symbolrate int(11) DEFAULT NULL,"
4211 " fec varchar(10) DEFAULT 'auto',"
4212 " polarity char(1) DEFAULT NULL,"
4213 " modulation varchar(10) DEFAULT 'auto',"
4214 " bandwidth char(1) DEFAULT 'a',"
4215 " lp_code_rate varchar(10) DEFAULT 'auto',"
4216 " transmission_mode char(1) DEFAULT 'a',"
4217 " guard_interval varchar(10) DEFAULT 'auto',"
4218 " visible smallint(1) NOT NULL DEFAULT '0',"
4219 " constellation varchar(10) DEFAULT 'auto',"
4220 " hierarchy varchar(10) DEFAULT 'auto',"
4221 " hp_code_rate varchar(10) DEFAULT 'auto',"
4222 " mod_sys varchar(10) DEFAULT NULL,"
4223 " rolloff varchar(4) DEFAULT NULL,"
4224 " sistandard varchar(10) DEFAULT 'dvb',"
4225 " serviceversion smallint(6) DEFAULT '33',"
4226 " updatetimestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4227 " default_authority varchar(32) NOT NULL DEFAULT '',"
4228 " PRIMARY KEY (mplexid)"
4229 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4230 "CREATE TABLE dtv_privatetypes ("
4231 " sitype varchar(4) NOT NULL DEFAULT '',"
4232 " networkid int(11) NOT NULL DEFAULT '0',"
4233 " private_type varchar(20) NOT NULL DEFAULT '',"
4234 " private_value varchar(100) NOT NULL DEFAULT ''"
4235 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4236 "CREATE TABLE dvdbookmark ("
4237 " serialid varchar(16) NOT NULL DEFAULT '',"
4238 " `name` varchar(32) DEFAULT NULL,"
4239 " title smallint(6) NOT NULL DEFAULT '0',"
4240 " audionum tinyint(4) NOT NULL DEFAULT '-1',"
4241 " subtitlenum tinyint(4) NOT NULL DEFAULT '-1',"
4242 " framenum bigint(20) NOT NULL DEFAULT '0',"
4243 " `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4244 " PRIMARY KEY (serialid)"
4245 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4246 "CREATE TABLE dvdinput ("
4247 " intid int(10) unsigned NOT NULL,"
4248 " hsize int(10) unsigned DEFAULT NULL,"
4249 " vsize int(10) unsigned DEFAULT NULL,"
4250 " ar_num int(10) unsigned DEFAULT NULL,"
4251 " ar_denom int(10) unsigned DEFAULT NULL,"
4252 " fr_code int(10) unsigned DEFAULT NULL,"
4253 " letterbox tinyint(1) DEFAULT NULL,"
4254 " v_format varchar(16) DEFAULT NULL,"
4255 " PRIMARY KEY (intid)"
4256 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4257 "CREATE TABLE dvdtranscode ("
4258 " intid int(11) NOT NULL AUTO_INCREMENT,"
4259 " input int(10) unsigned DEFAULT NULL,"
4260 " `name` varchar(128) NOT NULL,"
4261 " sync_mode int(10) unsigned DEFAULT NULL,"
4262 " use_yv12 tinyint(1) DEFAULT NULL,"
4263 " cliptop int(11) DEFAULT NULL,"
4264 " clipbottom int(11) DEFAULT NULL,"
4265 " clipleft int(11) DEFAULT NULL,"
4266 " clipright int(11) DEFAULT NULL,"
4267 " f_resize_h int(11) DEFAULT NULL,"
4268 " f_resize_w int(11) DEFAULT NULL,"
4269 " hq_resize_h int(11) DEFAULT NULL,"
4270 " hq_resize_w int(11) DEFAULT NULL,"
4271 " grow_h int(11) DEFAULT NULL,"
4272 " grow_w int(11) DEFAULT NULL,"
4273 " clip2top int(11) DEFAULT NULL,"
4274 " clip2bottom int(11) DEFAULT NULL,"
4275 " clip2left int(11) DEFAULT NULL,"
4276 " clip2right int(11) DEFAULT NULL,"
4277 " codec varchar(128) NOT NULL,"
4278 " codec_param varchar(128) DEFAULT NULL,"
4279 " bitrate int(11) DEFAULT NULL,"
4280 " a_sample_r int(11) DEFAULT NULL,"
4281 " a_bitrate int(11) DEFAULT NULL,"
4282 " two_pass tinyint(1) DEFAULT NULL,"
4283 " tc_param varchar(128) DEFAULT NULL,"
4284 " PRIMARY KEY (intid)"
4285 ") ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;",
4286 "CREATE TABLE eit_cache ("
4287 " chanid int(10) NOT NULL,"
4288 " eventid int(10) unsigned NOT NULL DEFAULT '0',"
4289 " tableid tinyint(3) unsigned NOT NULL,"
4290 " version tinyint(3) unsigned NOT NULL,"
4291 " endtime int(10) unsigned NOT NULL,"
4292 " `status` tinyint(4) NOT NULL DEFAULT '0',"
4293 " PRIMARY KEY (chanid,eventid,`status`)"
4294 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4295 "CREATE TABLE filemarkup ("
4296 " filename text NOT NULL,"
4297 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4298 " `offset` bigint(20) unsigned DEFAULT NULL,"
4299 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4300 " KEY filename (filename(255))"
4301 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4302 "CREATE TABLE housekeeping ("
4303 " tag varchar(64) NOT NULL DEFAULT '',"
4304 " lastrun datetime DEFAULT NULL,"
4305 " PRIMARY KEY (tag)"
4306 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4307 "CREATE TABLE inputgroup ("
4308 " cardinputid int(10) unsigned NOT NULL,"
4309 " inputgroupid int(10) unsigned NOT NULL,"
4310 " inputgroupname varchar(32) NOT NULL"
4311 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4312 "CREATE TABLE internetcontent ("
4313 " `name` varchar(255) NOT NULL,"
4314 " thumbnail varchar(255) DEFAULT NULL,"
4315 " `type` smallint(3) NOT NULL,"
4316 " author varchar(128) NOT NULL,"
4317 " description text NOT NULL,"
4318 " commandline text NOT NULL,"
4319 " version double NOT NULL,"
4320 " updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4321 " search tinyint(1) NOT NULL,"
4322 " tree tinyint(1) NOT NULL,"
4323 " podcast tinyint(1) NOT NULL,"
4324 " download tinyint(1) NOT NULL,"
4325 " `host` varchar(128) DEFAULT NULL"
4326 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4327 "CREATE TABLE internetcontentarticles ("
4328 " feedtitle varchar(255) NOT NULL,"
4329 " path text NOT NULL,"
4330 " paththumb text NOT NULL,"
4331 " title varchar(255) NOT NULL,"
4332 " subtitle varchar(255) NOT NULL,"
4333 " season smallint(5) NOT NULL DEFAULT '0',"
4334 " episode smallint(5) NOT NULL DEFAULT '0',"
4335 " description text NOT NULL,"
4336 " url text NOT NULL,"
4337 " `type` smallint(3) NOT NULL,"
4338 " thumbnail text NOT NULL,"
4339 " mediaURL text NOT NULL,"
4340 " author varchar(255) NOT NULL,"
4341 " `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4342 " `time` int(11) NOT NULL,"
4343 " rating varchar(255) NOT NULL,"
4344 " filesize bigint(20) NOT NULL,"
4345 " player varchar(255) NOT NULL,"
4346 " playerargs text NOT NULL,"
4347 " download varchar(255) NOT NULL,"
4348 " downloadargs text NOT NULL,"
4349 " width smallint(6) NOT NULL,"
4350 " height smallint(6) NOT NULL,"
4351 " `language` varchar(128) NOT NULL,"
4352 " podcast tinyint(1) NOT NULL,"
4353 " downloadable tinyint(1) NOT NULL,"
4354 " customhtml tinyint(1) NOT NULL,"
4355 " countries varchar(255) NOT NULL"
4356 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4357 "CREATE TABLE inuseprograms ("
4358 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4359 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4360 " recusage varchar(128) NOT NULL DEFAULT '',"
4361 " lastupdatetime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4362 " hostname varchar(64) NOT NULL DEFAULT '',"
4363 " rechost varchar(64) NOT NULL,"
4364 " recdir varchar(255) NOT NULL DEFAULT '',"
4365 " KEY chanid (chanid,starttime),"
4366 " KEY recusage (recusage,lastupdatetime)"
4367 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4368 "CREATE TABLE iptv_channel ("
4369 " iptvid smallint(6) unsigned NOT NULL AUTO_INCREMENT,"
4370 " chanid int(10) unsigned NOT NULL,"
4371 " url text NOT NULL,"
4372 " `type` set('data','rfc2733-1','rfc2733-2','rfc5109-1','rfc5109-2','smpte2022-1','smpte2022-2') DEFAULT NULL,"
4373 " bitrate int(10) unsigned NOT NULL,"
4374 " PRIMARY KEY (iptvid)"
4375 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4376 "CREATE TABLE jobqueue ("
4377 " id int(11) NOT NULL AUTO_INCREMENT,"
4378 " chanid int(10) NOT NULL DEFAULT '0',"
4379 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4380 " inserttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4381 " `type` int(11) NOT NULL DEFAULT '0',"
4382 " cmds int(11) NOT NULL DEFAULT '0',"
4383 " flags int(11) NOT NULL DEFAULT '0',"
4384 " `status` int(11) NOT NULL DEFAULT '0',"
4385 " statustime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4386 " hostname varchar(64) NOT NULL DEFAULT '',"
4387 " args blob NOT NULL,"
4388 " `comment` varchar(128) NOT NULL DEFAULT '',"
4389 " schedruntime datetime NOT NULL DEFAULT '2007-01-01 00:00:00',"
4390 " PRIMARY KEY (id),"
4391 " UNIQUE KEY chanid (chanid,starttime,`type`,inserttime)"
4392 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4393 "CREATE TABLE jumppoints ("
4394 " destination varchar(128) NOT NULL DEFAULT '',"
4395 " description varchar(255) DEFAULT NULL,"
4396 " keylist varchar(128) DEFAULT NULL,"
4397 " hostname varchar(64) NOT NULL DEFAULT '',"
4398 " PRIMARY KEY (destination,hostname)"
4399 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4400 "CREATE TABLE keybindings ("
4401 " `context` varchar(32) NOT NULL DEFAULT '',"
4402 " `action` varchar(32) NOT NULL DEFAULT '',"
4403 " description varchar(255) DEFAULT NULL,"
4404 " keylist varchar(128) DEFAULT NULL,"
4405 " hostname varchar(64) NOT NULL DEFAULT '',"
4406 " PRIMARY KEY (`context`,`action`,hostname)"
4407 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4408 "CREATE TABLE keyword ("
4409 " phrase varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4410 " searchtype int(10) unsigned NOT NULL DEFAULT '3',"
4411 " UNIQUE KEY phrase (phrase,searchtype)"
4412 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4413 "CREATE TABLE livestream ("
4414 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4415 " width int(10) unsigned NOT NULL,"
4416 " height int(10) unsigned NOT NULL,"
4417 " bitrate int(10) unsigned NOT NULL,"
4418 " audiobitrate int(10) unsigned NOT NULL,"
4419 " samplerate int(10) unsigned NOT NULL,"
4420 " audioonlybitrate int(10) unsigned NOT NULL,"
4421 " segmentsize int(10) unsigned NOT NULL DEFAULT '10',"
4422 " maxsegments int(10) unsigned NOT NULL DEFAULT '0',"
4423 " startsegment int(10) unsigned NOT NULL DEFAULT '0',"
4424 " currentsegment int(10) unsigned NOT NULL DEFAULT '0',"
4425 " segmentcount int(10) unsigned NOT NULL DEFAULT '0',"
4426 " percentcomplete int(10) unsigned NOT NULL DEFAULT '0',"
4427 " created datetime NOT NULL,"
4428 " lastmodified datetime NOT NULL,"
4429 " relativeurl varchar(512) NOT NULL,"
4430 " fullurl varchar(1024) NOT NULL,"
4431 " `status` int(10) unsigned NOT NULL DEFAULT '0',"
4432 " statusmessage varchar(256) NOT NULL,"
4433 " sourcefile varchar(512) NOT NULL,"
4434 " sourcehost varchar(64) NOT NULL,"
4435 " sourcewidth int(10) unsigned NOT NULL DEFAULT '0',"
4436 " sourceheight int(10) unsigned NOT NULL DEFAULT '0',"
4437 " outdir varchar(256) NOT NULL,"
4438 " outbase varchar(128) NOT NULL,"
4439 " PRIMARY KEY (id)"
4440 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4441 "CREATE TABLE logging ("
4442 " id bigint(20) unsigned NOT NULL AUTO_INCREMENT,"
4443 " `host` varchar(64) NOT NULL DEFAULT '',"
4444 " application varchar(64) NOT NULL DEFAULT '',"
4445 " pid int(11) NOT NULL DEFAULT '0',"
4446 " tid int(11) NOT NULL DEFAULT '0',"
4447 " thread varchar(64) NOT NULL DEFAULT '',"
4448 " filename varchar(255) NOT NULL DEFAULT '',"
4449 " line int(11) NOT NULL DEFAULT '0',"
4450 " `function` varchar(255) NOT NULL DEFAULT '',"
4451 " msgtime datetime NOT NULL,"
4452 " `level` int(11) NOT NULL DEFAULT '0',"
4453 " message varchar(2048) NOT NULL,"
4454 " PRIMARY KEY (id),"
4455 " KEY `host` (`host`,application,pid,msgtime),"
4456 " KEY msgtime (msgtime),"
4457 " KEY `level` (`level`)"
4458 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4459 "CREATE TABLE mythlog ("
4460 " logid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4461 " module varchar(32) NOT NULL DEFAULT '',"
4462 " priority int(11) NOT NULL DEFAULT '0',"
4463 " acknowledged tinyint(1) DEFAULT '0',"
4464 " logdate datetime DEFAULT NULL,"
4465 " `host` varchar(128) DEFAULT NULL,"
4466 " message varchar(255) NOT NULL DEFAULT '',"
4467 " details varchar(16000) NOT NULL DEFAULT '',"
4468 " PRIMARY KEY (logid),"
4469 " KEY module (module)"
4470 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4471 "CREATE TABLE oldfind ("
4472 " recordid int(11) NOT NULL DEFAULT '0',"
4473 " findid int(11) NOT NULL DEFAULT '0',"
4474 " PRIMARY KEY (recordid,findid)"
4475 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4476 "CREATE TABLE oldprogram ("
4477 " oldtitle varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4478 " airdate datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4479 " PRIMARY KEY (oldtitle)"
4480 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4481 "CREATE TABLE oldrecorded ("
4482 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4483 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4484 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4485 " title varchar(128) NOT NULL DEFAULT '',"
4486 " subtitle varchar(128) NOT NULL DEFAULT '',"
4487 " description varchar(16000) NOT NULL DEFAULT '',"
4488 " season smallint(5) NOT NULL,"
4489 " episode smallint(5) NOT NULL,"
4490 " category varchar(64) NOT NULL DEFAULT '',"
4491 " seriesid varchar(40) NOT NULL DEFAULT '',"
4492 " programid varchar(40) NOT NULL DEFAULT '',"
4493 " inetref varchar(40) NOT NULL,"
4494 " findid int(11) NOT NULL DEFAULT '0',"
4495 " recordid int(11) NOT NULL DEFAULT '0',"
4496 " station varchar(20) NOT NULL DEFAULT '',"
4497 " rectype int(10) unsigned NOT NULL DEFAULT '0',"
4498 " `duplicate` tinyint(1) NOT NULL DEFAULT '0',"
4499 " recstatus int(11) NOT NULL DEFAULT '0',"
4500 " reactivate smallint(6) NOT NULL DEFAULT '0',"
4501 " generic tinyint(1) NOT NULL,"
4502 " future tinyint(1) NOT NULL DEFAULT '0',"
4503 " PRIMARY KEY (station,starttime,title),"
4504 " KEY endtime (endtime),"
4505 " KEY title (title),"
4506 " KEY seriesid (seriesid),"
4507 " KEY programid (programid),"
4508 " KEY recordid (recordid),"
4509 " KEY recstatus (recstatus,programid,seriesid),"
4510 " KEY recstatus_2 (recstatus,title,subtitle),"
4511 " KEY future (future),"
4512 " KEY chanid (chanid,starttime),"
4513 " KEY subtitle (subtitle),"
4514 " KEY description (description(255))"
4515 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4516 "CREATE TABLE people ("
4517 " person mediumint(8) unsigned NOT NULL AUTO_INCREMENT,"
4518 " `name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4519 " PRIMARY KEY (person),"
4520 " UNIQUE KEY `name` (`name`(41))"
4521 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4522 "CREATE TABLE pidcache ("
4523 " chanid smallint(6) NOT NULL DEFAULT '0',"
4524 " pid int(11) NOT NULL DEFAULT '-1',"
4525 " tableid int(11) NOT NULL DEFAULT '-1',"
4526 " KEY chanid (chanid)"
4527 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4528 "CREATE TABLE playgroup ("
4529 " `name` varchar(32) NOT NULL DEFAULT '',"
4530 " titlematch varchar(255) NOT NULL DEFAULT '',"
4531 " skipahead int(11) NOT NULL DEFAULT '0',"
4532 " skipback int(11) NOT NULL DEFAULT '0',"
4533 " timestretch int(11) NOT NULL DEFAULT '0',"
4534 " jump int(11) NOT NULL DEFAULT '0',"
4535 " PRIMARY KEY (`name`)"
4536 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4537 "CREATE TABLE powerpriority ("
4538 " priorityname varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,"
4539 " recpriority int(10) NOT NULL DEFAULT '0',"
4540 " selectclause varchar(16000) NOT NULL DEFAULT '',"
4541 " PRIMARY KEY (priorityname)"
4542 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4543 "CREATE TABLE profilegroups ("
4544 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4545 " `name` varchar(128) DEFAULT NULL,"
4546 " cardtype varchar(32) NOT NULL DEFAULT 'V4L',"
4547 " is_default int(1) DEFAULT '0',"
4548 " hostname varchar(64) DEFAULT NULL,"
4549 " PRIMARY KEY (id),"
4550 " UNIQUE KEY `name` (`name`,hostname),"
4551 " KEY cardtype (cardtype)"
4552 ") ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;",
4553 "CREATE TABLE program ("
4554 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4555 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4556 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4557 " title varchar(128) NOT NULL DEFAULT '',"
4558 " subtitle varchar(128) NOT NULL DEFAULT '',"
4559 " description varchar(16000) NOT NULL DEFAULT '',"
4560 " category varchar(64) NOT NULL DEFAULT '',"
4561 " category_type varchar(64) NOT NULL DEFAULT '',"
4562 " airdate year(4) NOT NULL DEFAULT '0000',"
4563 " stars float NOT NULL DEFAULT '0',"
4564 " previouslyshown tinyint(4) NOT NULL DEFAULT '0',"
4565 " title_pronounce varchar(128) NOT NULL DEFAULT '',"
4566 " stereo tinyint(1) NOT NULL DEFAULT '0',"
4567 " subtitled tinyint(1) NOT NULL DEFAULT '0',"
4568 " hdtv tinyint(1) NOT NULL DEFAULT '0',"
4569 " closecaptioned tinyint(1) NOT NULL DEFAULT '0',"
4570 " partnumber int(11) NOT NULL DEFAULT '0',"
4571 " parttotal int(11) NOT NULL DEFAULT '0',"
4572 " seriesid varchar(64) NOT NULL DEFAULT '',"
4573 " originalairdate date DEFAULT NULL,"
4574 " showtype varchar(30) NOT NULL DEFAULT '',"
4575 " colorcode varchar(20) NOT NULL DEFAULT '',"
4576 " syndicatedepisodenumber varchar(20) NOT NULL DEFAULT '',"
4577 " programid varchar(64) NOT NULL DEFAULT '',"
4578 " manualid int(10) unsigned NOT NULL DEFAULT '0',"
4579 " generic tinyint(1) DEFAULT '0',"
4580 " listingsource int(11) NOT NULL DEFAULT '0',"
4581 " `first` tinyint(1) NOT NULL DEFAULT '0',"
4582 " `last` tinyint(1) NOT NULL DEFAULT '0',"
4583 " audioprop set('STEREO','MONO','SURROUND','DOLBY','HARDHEAR','VISUALIMPAIR') NOT NULL,"
4584 " subtitletypes set('HARDHEAR','NORMAL','ONSCREEN','SIGNED') NOT NULL,"
4585 " videoprop set('HDTV','WIDESCREEN','AVC') NOT NULL,"
4586 " PRIMARY KEY (chanid,starttime,manualid),"
4587 " KEY endtime (endtime),"
4588 " KEY title (title),"
4589 " KEY title_pronounce (title_pronounce),"
4590 " KEY seriesid (seriesid),"
4591 " KEY id_start_end (chanid,starttime,endtime),"
4592 " KEY program_manualid (manualid),"
4593 " KEY previouslyshown (previouslyshown),"
4594 " KEY programid (programid,starttime),"
4595 " KEY starttime (starttime),"
4596 " KEY subtitle (subtitle),"
4597 " KEY description (description(255))"
4598 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4599 "CREATE TABLE programgenres ("
4600 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4601 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4602 " relevance char(1) NOT NULL DEFAULT '',"
4603 " genre varchar(30) DEFAULT NULL,"
4604 " PRIMARY KEY (chanid,starttime,relevance),"
4605 " KEY genre (genre)"
4606 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4607 "CREATE TABLE programrating ("
4608 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4609 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4610 " `system` varchar(8) DEFAULT NULL,"
4611 " rating varchar(16) DEFAULT NULL,"
4612 " UNIQUE KEY chanid (chanid,starttime,`system`,rating),"
4613 " KEY starttime (starttime,`system`)"
4614 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4615 "CREATE TABLE recgrouppassword ("
4616 " recgroup varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4617 " `password` varchar(10) NOT NULL DEFAULT '',"
4618 " PRIMARY KEY (recgroup)"
4619 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4620 "CREATE TABLE record ("
4621 " recordid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4622 " `type` int(10) unsigned NOT NULL DEFAULT '0',"
4623 " chanid int(10) unsigned DEFAULT NULL,"
4624 " starttime time NOT NULL DEFAULT '00:00:00',"
4625 " startdate date NOT NULL DEFAULT '0000-00-00',"
4626 " endtime time NOT NULL DEFAULT '00:00:00',"
4627 " enddate date NOT NULL DEFAULT '0000-00-00',"
4628 " title varchar(128) NOT NULL DEFAULT '',"
4629 " subtitle varchar(128) NOT NULL DEFAULT '',"
4630 " description varchar(16000) NOT NULL DEFAULT '',"
4631 " season smallint(5) NOT NULL,"
4632 " episode smallint(5) NOT NULL,"
4633 " category varchar(64) NOT NULL DEFAULT '',"
4634 " `profile` varchar(128) NOT NULL DEFAULT 'Default',"
4635 " recpriority int(10) NOT NULL DEFAULT '0',"
4636 " autoexpire int(11) NOT NULL DEFAULT '0',"
4637 " maxepisodes int(11) NOT NULL DEFAULT '0',"
4638 " maxnewest int(11) NOT NULL DEFAULT '0',"
4639 " startoffset int(11) NOT NULL DEFAULT '0',"
4640 " endoffset int(11) NOT NULL DEFAULT '0',"
4641 " recgroup varchar(32) NOT NULL DEFAULT 'Default',"
4642 " dupmethod int(11) NOT NULL DEFAULT '6',"
4643 " dupin int(11) NOT NULL DEFAULT '15',"
4644 " station varchar(20) NOT NULL DEFAULT '',"
4645 " seriesid varchar(40) NOT NULL DEFAULT '',"
4646 " programid varchar(40) NOT NULL DEFAULT '',"
4647 " inetref varchar(40) NOT NULL,"
4648 " search int(10) unsigned NOT NULL DEFAULT '0',"
4649 " autotranscode tinyint(1) NOT NULL DEFAULT '0',"
4650 " autocommflag tinyint(1) NOT NULL DEFAULT '0',"
4651 " autouserjob1 tinyint(1) NOT NULL DEFAULT '0',"
4652 " autouserjob2 tinyint(1) NOT NULL DEFAULT '0',"
4653 " autouserjob3 tinyint(1) NOT NULL DEFAULT '0',"
4654 " autouserjob4 tinyint(1) NOT NULL DEFAULT '0',"
4655 " autometadata tinyint(1) NOT NULL DEFAULT '0',"
4656 " findday tinyint(4) NOT NULL DEFAULT '0',"
4657 " findtime time NOT NULL DEFAULT '00:00:00',"
4658 " findid int(11) NOT NULL DEFAULT '0',"
4659 " inactive tinyint(1) NOT NULL DEFAULT '0',"
4660 " parentid int(11) NOT NULL DEFAULT '0',"
4661 " transcoder int(11) NOT NULL DEFAULT '0',"
4662 " playgroup varchar(32) NOT NULL DEFAULT 'Default',"
4663 " prefinput int(10) NOT NULL DEFAULT '0',"
4664 " next_record datetime NOT NULL,"
4665 " last_record datetime NOT NULL,"
4666 " last_delete datetime NOT NULL,"
4667 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4668 " avg_delay int(11) NOT NULL DEFAULT '100',"
4669 " filter int(10) unsigned NOT NULL DEFAULT '0',"
4670 " PRIMARY KEY (recordid),"
4671 " KEY chanid (chanid,starttime),"
4672 " KEY title (title),"
4673 " KEY seriesid (seriesid),"
4674 " KEY programid (programid),"
4675 " KEY maxepisodes (maxepisodes),"
4676 " KEY search (search),"
4677 " KEY `type` (`type`)"
4678 ") ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;",
4679 "CREATE TABLE recorded ("
4680 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4681 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4682 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4683 " title varchar(128) NOT NULL DEFAULT '',"
4684 " subtitle varchar(128) NOT NULL DEFAULT '',"
4685 " description varchar(16000) NOT NULL DEFAULT '',"
4686 " season smallint(5) NOT NULL,"
4687 " episode smallint(5) NOT NULL,"
4688 " category varchar(64) NOT NULL DEFAULT '',"
4689 " hostname varchar(64) NOT NULL DEFAULT '',"
4690 " bookmark tinyint(1) NOT NULL DEFAULT '0',"
4691 " editing int(10) unsigned NOT NULL DEFAULT '0',"
4692 " cutlist tinyint(1) NOT NULL DEFAULT '0',"
4693 " autoexpire int(11) NOT NULL DEFAULT '0',"
4694 " commflagged int(10) unsigned NOT NULL DEFAULT '0',"
4695 " recgroup varchar(32) NOT NULL DEFAULT 'Default',"
4696 " recordid int(11) DEFAULT NULL,"
4697 " seriesid varchar(40) NOT NULL DEFAULT '',"
4698 " programid varchar(40) NOT NULL DEFAULT '',"
4699 " inetref varchar(40) NOT NULL,"
4700 " lastmodified timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,"
4701 " filesize bigint(20) NOT NULL DEFAULT '0',"
4702 " stars float NOT NULL DEFAULT '0',"
4703 " previouslyshown tinyint(1) DEFAULT '0',"
4704 " originalairdate date DEFAULT NULL,"
4705 " `preserve` tinyint(1) NOT NULL DEFAULT '0',"
4706 " findid int(11) NOT NULL DEFAULT '0',"
4707 " deletepending tinyint(1) NOT NULL DEFAULT '0',"
4708 " transcoder int(11) NOT NULL DEFAULT '0',"
4709 " timestretch float NOT NULL DEFAULT '1',"
4710 " recpriority int(11) NOT NULL DEFAULT '0',"
4711 " basename varchar(255) NOT NULL,"
4712 " progstart datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4713 " progend datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4714 " playgroup varchar(32) NOT NULL DEFAULT 'Default',"
4715 " `profile` varchar(32) NOT NULL DEFAULT '',"
4716 " `duplicate` tinyint(1) NOT NULL DEFAULT '0',"
4717 " transcoded tinyint(1) NOT NULL DEFAULT '0',"
4718 " watched tinyint(4) NOT NULL DEFAULT '0',"
4719 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4720 " bookmarkupdate timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',"
4721 " PRIMARY KEY (chanid,starttime),"
4722 " KEY endtime (endtime),"
4723 " KEY seriesid (seriesid),"
4724 " KEY programid (programid),"
4725 " KEY title (title),"
4726 " KEY recordid (recordid),"
4727 " KEY deletepending (deletepending,lastmodified),"
4728 " KEY recgroup (recgroup,endtime)"
4729 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4730 "CREATE TABLE recordedartwork ("
4731 " inetref varchar(255) NOT NULL,"
4732 " season smallint(5) NOT NULL,"
4733 " `host` text NOT NULL,"
4734 " coverart text NOT NULL,"
4735 " fanart text NOT NULL,"
4736 " banner text NOT NULL"
4737 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4738 "CREATE TABLE recordedcredits ("
4739 " person mediumint(8) unsigned NOT NULL DEFAULT '0',"
4740 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4741 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4742 " role set('actor','director','producer','executive_producer','writer','guest_star','host','adapter','presenter','commentator','guest') NOT NULL DEFAULT '',"
4743 " UNIQUE KEY chanid (chanid,starttime,person,role),"
4744 " KEY person (person,role)"
4745 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4746 "CREATE TABLE recordedfile ("
4747 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4748 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4749 " basename varchar(128) NOT NULL DEFAULT '',"
4750 " filesize bigint(20) NOT NULL DEFAULT '0',"
4751 " width smallint(5) unsigned NOT NULL DEFAULT '0',"
4752 " height smallint(5) unsigned NOT NULL DEFAULT '0',"
4753 " fps float(6,3) NOT NULL DEFAULT '0.000',"
4754 " aspect float(8,6) NOT NULL DEFAULT '0.000000',"
4755 " audio_sample_rate smallint(5) unsigned NOT NULL DEFAULT '0',"
4756 " audio_bits_per_sample smallint(5) unsigned NOT NULL DEFAULT '0',"
4757 " audio_channels tinyint(3) unsigned NOT NULL DEFAULT '0',"
4758 " audio_type varchar(255) NOT NULL DEFAULT '',"
4759 " video_type varchar(255) NOT NULL DEFAULT '',"
4760 " `comment` varchar(255) NOT NULL DEFAULT '',"
4761 " hostname varchar(64) NOT NULL,"
4762 " storagegroup varchar(32) NOT NULL,"
4763 " id int(11) NOT NULL AUTO_INCREMENT,"
4764 " PRIMARY KEY (id),"
4765 " UNIQUE KEY chanid (chanid,starttime,basename),"
4766 " KEY basename (basename)"
4767 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4768 "CREATE TABLE recordedmarkup ("
4769 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4770 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4771 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4772 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4773 " `data` int(11) unsigned DEFAULT NULL,"
4774 " PRIMARY KEY (chanid,starttime,`type`,mark)"
4775 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4776 "CREATE TABLE recordedprogram ("
4777 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4778 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4779 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4780 " title varchar(128) NOT NULL DEFAULT '',"
4781 " subtitle varchar(128) NOT NULL DEFAULT '',"
4782 " description varchar(16000) NOT NULL DEFAULT '',"
4783 " category varchar(64) NOT NULL DEFAULT '',"
4784 " category_type varchar(64) NOT NULL DEFAULT '',"
4785 " airdate year(4) NOT NULL DEFAULT '0000',"
4786 " stars float unsigned NOT NULL DEFAULT '0',"
4787 " previouslyshown tinyint(4) NOT NULL DEFAULT '0',"
4788 " title_pronounce varchar(128) NOT NULL DEFAULT '',"
4789 " stereo tinyint(1) NOT NULL DEFAULT '0',"
4790 " subtitled tinyint(1) NOT NULL DEFAULT '0',"
4791 " hdtv tinyint(1) NOT NULL DEFAULT '0',"
4792 " closecaptioned tinyint(1) NOT NULL DEFAULT '0',"
4793 " partnumber int(11) NOT NULL DEFAULT '0',"
4794 " parttotal int(11) NOT NULL DEFAULT '0',"
4795 " seriesid varchar(40) NOT NULL DEFAULT '',"
4796 " originalairdate date DEFAULT NULL,"
4797 " showtype varchar(30) NOT NULL DEFAULT '',"
4798 " colorcode varchar(20) NOT NULL DEFAULT '',"
4799 " syndicatedepisodenumber varchar(20) NOT NULL DEFAULT '',"
4800 " programid varchar(40) NOT NULL DEFAULT '',"
4801 " manualid int(10) unsigned NOT NULL DEFAULT '0',"
4802 " generic tinyint(1) DEFAULT '0',"
4803 " listingsource int(11) NOT NULL DEFAULT '0',"
4804 " `first` tinyint(1) NOT NULL DEFAULT '0',"
4805 " `last` tinyint(1) NOT NULL DEFAULT '0',"
4806 " audioprop set('STEREO','MONO','SURROUND','DOLBY','HARDHEAR','VISUALIMPAIR') NOT NULL,"
4807 " subtitletypes set('HARDHEAR','NORMAL','ONSCREEN','SIGNED') NOT NULL,"
4808 " videoprop set('HDTV','WIDESCREEN','AVC','720','1080','DAMAGED') NOT NULL,"
4809 " PRIMARY KEY (chanid,starttime,manualid),"
4810 " KEY endtime (endtime),"
4811 " KEY title (title),"
4812 " KEY title_pronounce (title_pronounce),"
4813 " KEY seriesid (seriesid),"
4814 " KEY programid (programid),"
4815 " KEY id_start_end (chanid,starttime,endtime)"
4816 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4817 "CREATE TABLE recordedrating ("
4818 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4819 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4820 " `system` varchar(8) DEFAULT NULL,"
4821 " rating varchar(16) DEFAULT NULL,"
4822 " UNIQUE KEY chanid (chanid,starttime,`system`,rating),"
4823 " KEY starttime (starttime,`system`)"
4824 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4825 "CREATE TABLE recordedseek ("
4826 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4827 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4828 " mark mediumint(8) unsigned NOT NULL DEFAULT '0',"
4829 " `offset` bigint(20) unsigned NOT NULL,"
4830 " `type` tinyint(4) NOT NULL DEFAULT '0',"
4831 " PRIMARY KEY (chanid,starttime,`type`,mark)"
4832 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4833 "CREATE TABLE recordfilter ("
4834 " filterid int(10) unsigned NOT NULL,"
4835 " description varchar(64) DEFAULT NULL,"
4836 " clause varchar(256) DEFAULT NULL,"
4837 " newruledefault tinyint(1) DEFAULT '0',"
4838 " PRIMARY KEY (filterid)"
4839 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4840 "CREATE TABLE recordingprofiles ("
4841 " id int(10) unsigned NOT NULL AUTO_INCREMENT,"
4842 " `name` varchar(128) DEFAULT NULL,"
4843 " videocodec varchar(128) DEFAULT NULL,"
4844 " audiocodec varchar(128) DEFAULT NULL,"
4845 " profilegroup int(10) unsigned NOT NULL DEFAULT '0',"
4846 " PRIMARY KEY (id),"
4847 " KEY profilegroup (profilegroup)"
4848 ") ENGINE=MyISAM AUTO_INCREMENT=70 DEFAULT CHARSET=utf8;",
4849 "CREATE TABLE recordmatch ("
4850 " recordid int(10) unsigned NOT NULL,"
4851 " chanid int(10) unsigned NOT NULL,"
4852 " starttime datetime NOT NULL,"
4853 " manualid int(10) unsigned NOT NULL,"
4854 " oldrecduplicate tinyint(1) DEFAULT NULL,"
4855 " recduplicate tinyint(1) DEFAULT NULL,"
4856 " findduplicate tinyint(1) DEFAULT NULL,"
4857 " oldrecstatus int(11) DEFAULT NULL,"
4858 " findid int(11) NOT NULL DEFAULT '0',"
4859 " UNIQUE KEY recordid (recordid,chanid,starttime),"
4860 " KEY chanid (chanid,starttime,manualid),"
4861 " KEY recordid_2 (recordid,findid)"
4862 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4863 "CREATE TABLE scannerfile ("
4864 " fileid bigint(20) unsigned NOT NULL AUTO_INCREMENT,"
4865 " filesize bigint(20) unsigned NOT NULL DEFAULT '0',"
4866 " filehash varchar(64) NOT NULL DEFAULT '',"
4867 " added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
4868 " PRIMARY KEY (fileid),"
4869 " UNIQUE KEY filehash (filehash)"
4870 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4871 "CREATE TABLE scannerpath ("
4872 " fileid bigint(20) unsigned NOT NULL,"
4873 " hostname varchar(64) NOT NULL DEFAULT 'localhost',"
4874 " storagegroup varchar(32) NOT NULL DEFAULT 'Default',"
4875 " filename varchar(255) NOT NULL DEFAULT '',"
4876 " PRIMARY KEY (fileid)"
4877 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4878 "CREATE TABLE settings ("
4879 " `value` varchar(128) NOT NULL DEFAULT '',"
4880 " `data` varchar(16000) NOT NULL DEFAULT '',"
4881 " hostname varchar(64) DEFAULT NULL,"
4882 " KEY `value` (`value`,hostname)"
4883 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4884 "CREATE TABLE storagegroup ("
4885 " id int(11) NOT NULL AUTO_INCREMENT,"
4886 " groupname varchar(32) NOT NULL,"
4887 " hostname varchar(64) NOT NULL DEFAULT '',"
4888 " dirname varchar(235) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',"
4889 " PRIMARY KEY (id),"
4890 " UNIQUE KEY grouphostdir (groupname,hostname,dirname),"
4891 " KEY hostname (hostname)"
4892 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4893 "CREATE TABLE tvchain ("
4894 " chanid int(10) unsigned NOT NULL DEFAULT '0',"
4895 " starttime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4896 " chainid varchar(128) NOT NULL DEFAULT '',"
4897 " chainpos int(10) NOT NULL DEFAULT '0',"
4898 " discontinuity tinyint(1) NOT NULL DEFAULT '0',"
4899 " watching int(10) NOT NULL DEFAULT '0',"
4900 " hostprefix varchar(128) NOT NULL DEFAULT '',"
4901 " cardtype varchar(32) NOT NULL DEFAULT 'V4L',"
4902 " input varchar(32) NOT NULL DEFAULT '',"
4903 " channame varchar(32) NOT NULL DEFAULT '',"
4904 " endtime datetime NOT NULL DEFAULT '0000-00-00 00:00:00',"
4905 " PRIMARY KEY (chanid,starttime)"
4906 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4907 "CREATE TABLE tvosdmenu ("
4908 " osdcategory varchar(32) NOT NULL,"
4909 " livetv tinyint(4) NOT NULL DEFAULT '0',"
4910 " recorded tinyint(4) NOT NULL DEFAULT '0',"
4911 " video tinyint(4) NOT NULL DEFAULT '0',"
4912 " dvd tinyint(4) NOT NULL DEFAULT '0',"
4913 " description varchar(32) NOT NULL,"
4914 " PRIMARY KEY (osdcategory)"
4915 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4916 "CREATE TABLE upnpmedia ("
4917 " intid int(10) unsigned NOT NULL DEFAULT '0',"
4918 " class varchar(64) NOT NULL DEFAULT '',"
4919 " itemtype varchar(128) NOT NULL DEFAULT '',"
4920 " parentid int(10) unsigned NOT NULL DEFAULT '0',"
4921 " itemproperties varchar(255) NOT NULL DEFAULT '',"
4922 " filepath varchar(512) NOT NULL DEFAULT '',"
4923 " title varchar(255) NOT NULL DEFAULT '',"
4924 " filename varchar(512) NOT NULL DEFAULT '',"
4925 " coverart varchar(512) NOT NULL DEFAULT '',"
4926 " PRIMARY KEY (intid),"
4927 " KEY class (class),"
4928 " KEY filepath (filepath(333)),"
4929 " KEY parentid (parentid)"
4930 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4931 "CREATE TABLE videocast ("
4932 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4933 " cast varchar(128) NOT NULL,"
4934 " PRIMARY KEY (intid)"
4935 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4936 "CREATE TABLE videocategory ("
4937 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4938 " category varchar(128) NOT NULL,"
4939 " PRIMARY KEY (intid)"
4940 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4941 "CREATE TABLE videocollection ("
4942 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4943 " title varchar(256) NOT NULL,"
4944 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
4945 " plot text,"
4946 " network varchar(128) DEFAULT NULL,"
4947 " collectionref varchar(128) NOT NULL,"
4948 " certification varchar(128) DEFAULT NULL,"
4949 " genre varchar(128) DEFAULT '',"
4950 " releasedate date DEFAULT NULL,"
4951 " `language` varchar(10) DEFAULT NULL,"
4952 " `status` varchar(64) DEFAULT NULL,"
4953 " rating float DEFAULT '0',"
4954 " ratingcount int(10) DEFAULT '0',"
4955 " runtime smallint(5) unsigned DEFAULT '0',"
4956 " banner text,"
4957 " fanart text,"
4958 " coverart text,"
4959 " PRIMARY KEY (intid),"
4960 " KEY title (title)"
4961 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4962 "CREATE TABLE videocountry ("
4963 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4964 " country varchar(128) NOT NULL,"
4965 " PRIMARY KEY (intid)"
4966 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4967 "CREATE TABLE videogenre ("
4968 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4969 " genre varchar(128) NOT NULL,"
4970 " PRIMARY KEY (intid)"
4971 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
4972 "CREATE TABLE videometadata ("
4973 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
4974 " title varchar(128) NOT NULL,"
4975 " subtitle text NOT NULL,"
4976 " tagline varchar(255) DEFAULT NULL,"
4977 " director varchar(128) NOT NULL,"
4978 " studio varchar(128) DEFAULT NULL,"
4979 " plot text,"
4980 " rating varchar(128) NOT NULL,"
4981 " inetref varchar(255) NOT NULL,"
4982 " collectionref int(10) NOT NULL DEFAULT '-1',"
4983 " homepage text NOT NULL,"
4984 " `year` int(10) unsigned NOT NULL,"
4985 " releasedate date NOT NULL,"
4986 " userrating float NOT NULL,"
4987 " length int(10) unsigned NOT NULL,"
4988 " playcount int(10) NOT NULL DEFAULT '0',"
4989 " season smallint(5) unsigned NOT NULL DEFAULT '0',"
4990 " episode smallint(5) unsigned NOT NULL DEFAULT '0',"
4991 " showlevel int(10) unsigned NOT NULL,"
4992 " filename text NOT NULL,"
4993 " `hash` varchar(128) NOT NULL,"
4994 " coverfile text NOT NULL,"
4995 " childid int(11) NOT NULL DEFAULT '-1',"
4996 " browse tinyint(1) NOT NULL DEFAULT '1',"
4997 " watched tinyint(1) NOT NULL DEFAULT '0',"
4998 " processed tinyint(1) NOT NULL DEFAULT '0',"
4999 " playcommand varchar(255) DEFAULT NULL,"
5000 " category int(10) unsigned NOT NULL DEFAULT '0',"
5001 " trailer text,"
5002 " `host` text NOT NULL,"
5003 " screenshot text,"
5004 " banner text,"
5005 " fanart text,"
5006 " insertdate timestamp NULL DEFAULT CURRENT_TIMESTAMP,"
5007 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
5008 " PRIMARY KEY (intid),"
5009 " KEY director (director),"
5010 " KEY title (title)"
5011 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5012 "CREATE TABLE videometadatacast ("
5013 " idvideo int(10) unsigned NOT NULL,"
5014 " idcast int(10) unsigned NOT NULL,"
5015 " UNIQUE KEY idvideo (idvideo,idcast)"
5016 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5017 "CREATE TABLE videometadatacountry ("
5018 " idvideo int(10) unsigned NOT NULL,"
5019 " idcountry int(10) unsigned NOT NULL,"
5020 " UNIQUE KEY idvideo_2 (idvideo,idcountry),"
5021 " KEY idvideo (idvideo),"
5022 " KEY idcountry (idcountry)"
5023 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5024 "CREATE TABLE videometadatagenre ("
5025 " idvideo int(10) unsigned NOT NULL,"
5026 " idgenre int(10) unsigned NOT NULL,"
5027 " UNIQUE KEY idvideo_2 (idvideo,idgenre),"
5028 " KEY idvideo (idvideo),"
5029 " KEY idgenre (idgenre)"
5030 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5031 "CREATE TABLE videopart ("
5032 " fileid bigint(20) unsigned NOT NULL,"
5033 " videoid int(10) unsigned NOT NULL,"
5034 " `order` smallint(5) unsigned NOT NULL DEFAULT '1',"
5035 " PRIMARY KEY (videoid,`order`)"
5036 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5037 "CREATE TABLE videopathinfo ("
5038 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
5039 " path text,"
5040 " contenttype set('MOVIE','TELEVISION','ADULT','MUSICVIDEO','HOMEVIDEO') NOT NULL DEFAULT '',"
5041 " collectionref int(10) DEFAULT '0',"
5042 " recurse tinyint(1) DEFAULT '0',"
5043 " PRIMARY KEY (intid)"
5044 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5045 "CREATE TABLE videosource ("
5046 " sourceid int(10) unsigned NOT NULL AUTO_INCREMENT,"
5047 " `name` varchar(128) NOT NULL DEFAULT '',"
5048 " xmltvgrabber varchar(128) DEFAULT NULL,"
5049 " userid varchar(128) NOT NULL DEFAULT '',"
5050 " freqtable varchar(16) NOT NULL DEFAULT 'default',"
5051 " lineupid varchar(64) DEFAULT NULL,"
5052 " `password` varchar(64) DEFAULT NULL,"
5053 " useeit smallint(6) NOT NULL DEFAULT '0',"
5054 " configpath varchar(4096) DEFAULT NULL,"
5055 " dvb_nit_id int(6) DEFAULT '-1',"
5056 " PRIMARY KEY (sourceid),"
5057 " UNIQUE KEY `name` (`name`)"
5058 ") ENGINE=MyISAM DEFAULT CHARSET=utf8;",
5059 "CREATE TABLE videotypes ("
5060 " intid int(10) unsigned NOT NULL AUTO_INCREMENT,"
5061 " extension varchar(128) NOT NULL,"
5062 " playcommand varchar(255) NOT NULL,"
5063 " f_ignore tinyint(1) DEFAULT NULL,"
5064 " use_default tinyint(1) DEFAULT NULL,"
5065 " PRIMARY KEY (intid)"
5066 ") ENGINE=MyISAM AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;",
5067 
5068 "INSERT INTO channelgroupnames VALUES (1,'Favorites');",
5069 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);"
5070 };
5071 
5072  QString dbver = "";
5073  if (!performActualUpdate("MythTV", "DBSchemaVer",
5074  updates, "1307", dbver))
5075  return false;
5076 
5077  GetMythDB()->SetHaveSchema(true);
5078 
5079  return true;
5080 }
5081 
5082 DBUpdates getRecordingExtenderDbInfo (int version)
5083 {
5084  switch (version)
5085  {
5086  case -1:
5087  return {
5088  R"(DROP TABLE IF EXISTS sportscleanup;)",
5089  R"(DROP TABLE IF EXISTS sportslisting;)",
5090  R"(DROP TABLE IF EXISTS sportsapi;)",
5091  };
5092 
5093  case 0:
5094  return {
5095  R"(ALTER TABLE record ADD COLUMN autoextend
5096  TINYINT UNSIGNED DEFAULT 0;)",
5097  };
5098 
5099  case 1:
5100  return {
5101  R"(CREATE TABLE sportsapi (
5102  id INT UNSIGNED PRIMARY KEY,
5103  provider TINYINT UNSIGNED DEFAULT 0,
5104  name VARCHAR(128) NOT NULL,
5105  key1 VARCHAR(64) NOT NULL,
5106  key2 VARCHAR(64) NOT NULL,
5107  UNIQUE(provider,key1(25),key2(50))
5108  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;)",
5109  R"(INSERT INTO sportsapi
5110  VALUES
5111  ( 1,1,"Major League Baseball","baseball","mlb"),
5112  ( 2,1,"NCAA Men's Baseball","baseball","college-baseball"),
5113  ( 3,1,"NCAA Women's Softball","baseball","college-softball"),
5114  ( 4,1,"Olympic Men's Baseball","baseball","olympics-baseball"),
5115  ( 5,1,"World Baseball Classic","baseball","world-baseball-classic"),
5116  ( 6,1,"Little League Baseball","baseball","llb"),
5117  ( 7,1,"Caribbean Series","baseball","caribbean-series"),
5118  ( 8,1,"Dominican Winter League","baseball","dominican-winter-league"),
5119  ( 9,1,"Venezuelan Winter League","baseball","venezuelan-winter-league"),
5120  ( 10,1,"Mexican League","baseball","mexican-winter-league"),
5121  ( 11,1,"Puerto Rican Winter League","baseball","puerto-rican-winter-league");)",
5122 
5123  R"(INSERT INTO sportsapi
5124  VALUES
5125  ( 20,1,"National Football League","football","nfl"),
5126  ( 21,1,"NCAA - Football","football","college-football"),
5127  ( 22,1,"XFL","football","xfl"),
5128  ( 23,1,"Canadian Football League","football","cfl");)",
5129 
5130  R"(INSERT INTO sportsapi
5131  VALUES
5132  ( 40,1,"National Basketball Association","basketball","nba"),
5133  ( 41,1,"Women's National Basketball Association","basketball","wnba"),
5134  ( 42,1,"NCAA Men's Basketball","basketball","mens-college-basketball"),
5135  ( 43,1,"NCAA Women's Basketball","basketball","womens-college-basketball"),
5136  ( 44,1,"Olympics Men's Basketball","basketball","mens-olympic-basketball"),
5137  ( 45,1,"Olympics Women's Basketball","basketball","womens-olympic-basketball"),
5138  ( 46,1,"National Basketball Association Summer League Las Vegas","basketball","nba-summer-las-vegas"),
5139  ( 47,1,"National Basketball Association Summer League Utah","basketball","nba-summer-utah"),
5140  ( 48,1,"National Basketball Association Summer League Orlando","basketball","nba-summer-orlando"),
5141  ( 49,1,"National Basketball Association Summer League Sacramento","basketball","nba-summer-sacramento"),
5142  ( 50,1,"NBA G League","basketball","nba-development"),
5143  ( 51,1,"International Basketball Federation","basketball","fiba");)",
5144 
5145  R"(INSERT INTO sportsapi
5146  VALUES
5147  ( 60,1,"National Hockey League","hockey","nfl"),
5148  ( 61,1,"NCAA Men's Ice Hockey","hockey","mens-college-hockey"),
5149  ( 62,1,"NCAA Women's Hockey","hockey","womens-college-hockey"),
5150  ( 63,1,"World Cup of Hockey","hockey","hockey-world-cup"),
5151  ( 64,1,"Men's Olympic Ice Hockey","hockey","mens-olympic-hockey"),
5152  ( 65,1,"Women's Olympic Ice Hockey","hockey","womens-olympic-hockey"),
5153  ( 66,1,"NCAA Women's Field Hockey","field-hockey","womens-college-field-hockey");)",
5154 
5155  R"(INSERT INTO sportsapi
5156  VALUES
5157  ( 80,1,"NCAA Men's Volleyball","volleyball","mens-college-volleyball"),
5158  ( 81,1,"NCAA Women's Volleyball","volleyball","womens-college-volleyball");)",
5159 
5160  R"(INSERT INTO sportsapi
5161  VALUES
5162  ( 100,1,"NCAA Men's Lacrosse","lacrosse","mens-college-lacrosse"),
5163  ( 101,1,"NCAA Women's Lacrosse","lacrosse","womens-college-lacrosse");)",
5164 
5165  R"(INSERT INTO sportsapi
5166  VALUES
5167  ( 120,1,"NCAA Men's Water Polo","water-polo","mens-college-water-polo"),
5168  ( 121,1,"NCAA Women's Water Polo","water-polo","womens-college-water-polo");)",
5169 
5170  R"(INSERT INTO sportsapi
5171  VALUES
5172  ( 200,1,"NCAA Men's Soccer","soccer","usa.ncaa.m.1"),
5173  ( 201,1,"NCAA Women's Soccer","soccer","usa.ncaa.w.1"),
5174  ( 202,1,"Major League Soccer","soccer","usa.1"),
5175  ( 203,1,"English Premier League","soccer","eng.1"),
5176  ( 204,1,"English League Championship","soccer","eng.2"),
5177  ( 205,1,"Italian Serie A","soccer","ita.1"),
5178  ( 206,1,"French Ligue 1","soccer","fra.1"),
5179  ( 207,1,"French Ligue 2","soccer","fra.2"),
5180  ( 208,1,"Spanish LaLiga","soccer","esp.1"),
5181  ( 209,1,"German Bundesliga","soccer","ger.1"),
5182  ( 210,1,"German 2. Bundesliga","soccer","ger.2"),
5183  ( 211,1,"Mexican Liga BBVA MX","soccer","mex.1"),
5184  ( 212,1,"Copa Do Brasil","soccer","bra.copa_do_brazil"),
5185  ( 213,1,"CONCACAF Leagues Cup","soccer","concacaf.leagues.cup"),
5186  ( 214,1,"CONCACAF League","soccer","concacaf.league"),
5187  ( 215,1,"CONCACAF Champions League","soccer","concacaf.champions"),
5188  ( 216,1,"CONCACAF Nations League","soccer","concacaf.nations.league"),
5189  ( 217,1,"CONCACAF Gold Cup","soccer","concacaf.gold"),
5190  ( 218,1,"FIFA World Cup","soccer","fifa.world"),
5191  ( 219,1,"FIFA World Cup Qualifying - UEFA","soccer","fifa.worldq.uefa"),
5192  ( 220,1,"FIFA World Cup Qualifying - CONCACAF","soccer","fifa.worldq.concacaf"),
5193  ( 221,1,"FIFA World Cup Qualifying - CONMEBOL","soccer","fifa.worldq.conmebol"),
5194  ( 222,1,"FIFA World Cup Qualifying - AFC","soccer","fifa.worldq.afc"),
5195  ( 223,1,"FIFA World Cup Qualifying - CAF","soccer","fifa.worldq.caf"),
5196  ( 224,1,"FIFA World Cup Qualifying - OFC","soccer","fifa.worldq.ofc"),
5197  ( 225,1,"UEFA Champions League","soccer","uefa.champions"),
5198  ( 226,1,"UEFA Europa League","soccer","uefa.europa"),
5199  ( 227,1,"UEFA Europa Conference League","soccer","uefa.europa.conf"),
5200  ( 228,1,"English Carabao Cup","soccer","eng.league_cup"),
5201  ( 229,1,"USL Championship","soccer","usa.usl.1"),
5202  ( 230,1,"United States NWSL","soccer","usa.nwsl"),
5203  ( 231,1,"FA Women's Super League","soccer","eng.w.1"),
5204  ( 232,1,"English FA Cup","soccer","eng.fa"),
5205  ( 233,1,"Spanish Copa del Rey","soccer","esp.copa_del_rey"),
5206  ( 234,1,"German DFB Pokal","soccer","ger.dfb_pokal"),
5207  ( 235,1,"Italian Coppa Italia","soccer","ita.coppa_italia"),
5208  ( 236,1,"French Coupe de France","soccer","fra.coupe_de_france"),
5209  ( 237,1,"AFC Champions League","soccer","afc.champions"),
5210  ( 238,1,"Dutch KNVB Beker","soccer","ned.cup"),
5211  ( 239,1,"Dutch Eredivisie","soccer","ned.1"),
5212  ( 240,1,"Portuguese Liga","soccer","por.1"),
5213  ( 241,1,"Russian Premier League","soccer","rus.1"),
5214  ( 242,1,"Mexican Liga de Expansión MX","soccer","mex.2"),
5215  ( 243,1,"Mexican Copa MX","soccer","mex.copa_mx"),
5216  ( 244,1,"Campeones Cup","soccer","campeones.cup"),
5217  ( 245,1,"United States Open Cup","soccer","usa.open"),
5218  ( 246,1,"USL League One","soccer","usa.usl.l1"),
5219  ( 247,1,"Scottish Premiership","soccer","sco.1"),
5220  ( 248,1,"Chinese Super League","soccer","chn.1"),
5221  ( 249,1,"Australian A-League","soccer","aus.1"),
5222  ( 250,1,"International Friendly","soccer","fifa.friendly"),
5223  ( 251,1,"Women's International Friendly","soccer","fifa.friendly.w"),
5224  ( 252,1,"UEFA European Under-21 Championship Qualifying","soccer","uefa.euro_u21_qual"),
5225  ( 253,1,"FIFA Women's World Cup","soccer","fifa.wwc"),
5226  ( 254,1,"FIFA Club World Cup","soccer","fifa.cwc"),
5227  ( 255,1,"CONCACAF Gold Cup Qualifying","soccer","concacaf.gold_qual"),
5228  ( 256,1,"CONCACAF Nations League Qualifying","soccer","concacaf.nations.league_qual"),
5229  ( 257,1,"CONCACAF Cup","soccer","concacaf.confederations_playoff"),
5230  ( 258,1,"UEFA Nations League","soccer","uefa.nations"),
5231  ( 259,1,"UEFA European Championship","soccer","uefa.euro"),
5232  ( 260,1,"UEFA European Championship Qualifying","soccer","uefa.euroq"),
5233  ( 261,1,"Copa America","soccer","conmebol.america"),
5234  ( 262,1,"AFC Asian Cup","soccer","afc.asian.cup"),
5235  ( 263,1,"AFC Asian Cup Qualifiers","soccer","afc.cupq"),
5236  ( 264,1,"Africa Cup of Nations qualifying","soccer","caf.nations_qual"),
5237  ( 265,1,"Africa Cup of Nations","soccer","caf.nations"),
5238  ( 266,1,"Africa Nations Championship","soccer","caf.championship"),
5239  ( 267,1,"WAFU Cup of Nations","soccer","wafu.nations"),
5240  ( 268,1,"SheBelieves Cup","soccer","fifa.shebelieves"),
5241  ( 269,1,"FIFA Confederations Cup","soccer","fifa.confederations"),
5242  ( 270,1,"Non-FIFA Friendly","soccer","nonfifa"),
5243  ( 271,1,"Spanish LaLiga 2","soccer","esp.2"),
5244  ( 272,1,"Spanish Supercopa","soccer","esp.super_cup"),
5245  ( 273,1,"Portuguese Liga Promotion/Relegation Playoffs","soccer","por.1.promotion.relegation"),
5246  ( 274,1,"Belgian First Division A - Promotion/Relegation Playoffs","soccer","bel.promotion.relegation"),
5247  ( 275,1,"Belgian First Division A","soccer","bel.1"),
5248  ( 276,1,"Austrian Bundesliga","soccer","aut.1"),
5249  ( 277,1,"Turkish Super Lig","soccer","tur.1"),
5250  ( 278,1,"Austrian Bundesliga Promotion/Relegation Playoffs","soccer","aut.promotion.relegation"),
5251  ( 279,1,"Greek Super League","soccer","gre.1"),
5252  ( 280,1,"Greek Super League Promotion/Relegation Playoffs","soccer","gre.1.promotion.relegation"),
5253  ( 281,1,"Swiss Super League","soccer","sui.1"),
5254  ( 282,1,"Swiss Super League Promotion/Relegation Playoffs","soccer","sui.1.promotion.relegation"),
5255  ( 283,1,"UEFA Women's Champions League","soccer","uefa.wchampions"),
5256  ( 284,1,"International Champions Cup","soccer","global.champs_cup"),
5257  ( 285,1,"Women's International Champions Cup","soccer","global.wchamps_cup"),
5258  ( 286,1,"Club Friendly","soccer","club.friendly"),
5259  ( 287,1,"UEFA Champions League Qualifying","soccer","uefa.champions_qual"),
5260  ( 288,1,"UEFA Europa Conference League Qualifying","soccer","uefa.europa.conf_qual"),
5261  ( 289,1,"UEFA Europa League Qualifying","soccer","uefa.europa_qual"),
5262  ( 290,1,"UEFA Super Cup","soccer","uefa.super_cup"),
5263  ( 291,1,"English FA Community Shield","soccer","eng.charity"),
5264  ( 292,1,"Supercoppa Italiana","soccer","ita.super_cup"),
5265  ( 293,1,"French Trophee des Champions","soccer","fra.super_cup"),
5266  ( 294,1,"Dutch Johan Cruyff Shield","soccer","ned.supercup"),
5267  ( 295,1,"Trofeo Joan Gamper","soccer","esp.joan_gamper"),
5268  ( 296,1,"German DFL-Supercup","soccer","ger.super_cup"),
5269  ( 297,1,"Audi Cup","soccer","ger.audi_cup"),
5270  ( 298,1,"Premier League Asia Trophy","soccer","eng.asia_trophy"),
5271  ( 299,1,"Emirates Cup","soccer","friendly.emirates_cup"),
5272  ( 300,1,"Japanese J League World Challenge","soccer","jpn.world_challenge"),
5273  ( 301,1,"SuperCopa Euroamericana","soccer","euroamericana.supercopa"),
5274  ( 302,1,"Men's Olympic Tournament","soccer","fifa.olympics"),
5275  ( 303,1,"Women's Olympic Tournament","soccer","fifa.w.olympics"),
5276  ( 304,1,"CONMEBOL Pre-Olympic Tournament","soccer","fifa.conmebol.olympicsq"),
5277  ( 305,1,"CONCACAF Men's Olympic Qualifying","soccer","fifa.concacaf.olympicsq"),
5278  ( 306,1,"CONCACAF Women's Olympic Qualifying Tournament","soccer","fifa.w.concacaf.olympicsq"),
5279  ( 307,1,"CONCACAF Women's Championship","soccer","concacaf.womens.championship"),
5280  ( 308,1,"FIFA Under-20 World Cup","soccer","fifa.world.u20"),
5281  ( 309,1,"FIFA Under-17 World Cup","soccer","fifa.world.u17"),
5282  ( 310,1,"Toulon Tournament","soccer","global.toulon"),
5283  ( 311,1,"UEFA European Under-21 Championship","soccer","uefa.euro_u21"),
5284  ( 312,1,"UEFA European Under-19 Championship","soccer","uefa.euro.u19"),
5285  ( 313,1,"Under-21 International Friendly","soccer","fifa.friendly_u21"),
5286  ( 314,1,"UEFA Women's European Championship","soccer","uefa.weuro"),
5287  ( 315,1,"German Bundesliga Promotion/Relegation Playoff","soccer","ger.playoff.relegation"),
5288  ( 316,1,"German 2. Bundesliga Promotion/Relegation Playoffs","soccer","ger.2.promotion.relegation"),
5289  ( 317,1,"English Women's FA Cup","soccer","eng.w.fa"),
5290  ( 318,1,"English Women's FA Community Shield","soccer","eng.w.charity"),
5291  ( 319,1,"English EFL Trophy","soccer","eng.trophy"),
5292  ( 320,1,"English National League","soccer","eng.5"),
5293  ( 321,1,"English League One","soccer","eng.3"),
5294  ( 322,1,"English League Two","soccer","eng.4"),
5295  ( 323,1,"Scottish Cup","soccer","sco.tennents"),
5296  ( 324,1,"Scottish League Cup","soccer","sco.cis"),
5297  ( 325,1,"Scottish Premiership Promotion/Relegation Playoffs","soccer","sco.1.promotion.relegation"),
5298  ( 326,1,"Scottish League One","soccer","sco.3"),
5299  ( 327,1,"Scottish Championship","soccer","sco.2"),
5300  ( 328,1,"Scottish Championship Promotion/Relegation Playoffs","soccer","sco.2.promotion.relegation"),
5301  ( 329,1,"Scottish League One Promotion/Relegation Playoffs","soccer","sco.3.promotion.relegation"),
5302  ( 330,1,"Scottish League Two Promotion/Relegation Playoffs","soccer","sco.4.promotion.relegation"),
5303  ( 331,1,"Scottish League Two","soccer","sco.4"),
5304  ( 332,1,"Scottish League Challenge Cup","soccer","sco.challenge"),
5305  ( 333,1,"Dutch Eredivisie Promotion/Relegation Playoffs","soccer","ned.playoff.relegation"),
5306  ( 334,1,"Dutch Eredivisie Cup","soccer","ned.w.eredivisie_cup"),
5307  ( 335,1,"Dutch Keuken Kampioen Divisie","soccer","ned.2"),
5308  ( 336,1,"Dutch Tweede Divisie","soccer","ned.3"),
5309  ( 337,1,"Dutch KNVB Beker Vrouwen","soccer","ned.w.knvb_cup"),
5310  ( 338,1,"Dutch Vrouwen Eredivisie","soccer","ned.w.1"),
5311  ( 339,1,"Italian Serie B","soccer","ita.2"),
5312  ( 340,1,"French Ligue 1 Promotion/Relegation Playoffs","soccer","fra.1.promotion.relegation"),
5313  ( 341,1,"French Ligue 2 Promotion/Relegation Playoffs","soccer","fra.2.promotion.relegation"),
5314  ( 342,1,"Swedish Allsvenskan","soccer","swe.1"),
5315  ( 343,1,"Swedish Allsvenskanliga Promotion/Relegation Playoffs","soccer","swe.1.promotion.relegation"),
5316  ( 344,1,"Danish Superliga","soccer","den.1"),
5317  ( 345,1,"Danish SAS-Ligaen Promotion/Relegation Playoffs","soccer","den.promotion.relegation"),
5318  ( 346,1,"Romanian Liga 1 Promotion/Relegation Playoffs","soccer","rou.1.promotion.relegation"),
5319  ( 347,1,"Romanian Liga 1","soccer","rou.1"),
5320  ( 348,1,"Norwegian Eliteserien Promotion/Relegation Playoffs","soccer","nor.1.promotion.relegation"),
5321  ( 349,1,"Norwegian Eliteserien","soccer","nor.1"),
5322  ( 350,1,"Maltese Premier League","soccer","mlt.1"),
5323  ( 351,1,"Israeli Premier League","soccer","isr.1"),
5324  ( 352,1,"Irish Premier Division Promotion/Relegation Playoffs","soccer","ir1.1.promotion.relegation"),
5325  ( 353,1,"Irish Premier Division","soccer","irl.1"),
5326  ( 354,1,"Welsh Premier League","soccer","wal.1"),
5327  ( 355,1,"Northern Irish Premiership","soccer","nir.1"),
5328  ( 356,1,"CONMEBOL Copa Libertadores","soccer","conmebol.libertadores"),
5329  ( 357,1,"CONMEBOL Copa Sudamericana","soccer","conmebol.sudamericana"),
5330  ( 358,1,"CONMEBOL Recopa Sudamericana","soccer","conmebol.recopa"),
5331  ( 359,1,"Argentine Liga Profesional de Fútbol","soccer","arg.1"),
5332  ( 360,1,"Copa Argentina","soccer","arg.copa"),
5333  ( 361,1,"Argentine Copa de la Liga Profesional","soccer","arg.copa_lpf"),
5334  ( 362,1,"Argentine Copa de la Superliga","soccer","arg.copa_de_la_superliga"),
5335  ( 363,1,"Argentine Trofeo de Campeones de la Superliga","soccer","arg.trofeo_de_la_campeones"),
5336  ( 364,1,"Argentine Supercopa","soccer","arg.supercopa"),
5337  ( 365,1,"Argentine Nacional B","soccer","arg.2"),
5338  ( 366,1,"Argentine Primera B","soccer","arg.3"),
5339  ( 367,1,"Argentine Primera C","soccer","arg.4"),
5340  ( 368,1,"Argentine Primera D","soccer","arg.5"),
5341  ( 369,1,"Supercopa Do Brazil","soccer","bra.supercopa_do_brazil"),
5342  ( 370,1,"Brazilian Serie A","soccer","bra.1"),
5343  ( 371,1,"Brazilian Serie B","soccer","bra.2"),
5344  ( 372,1,"Brazilian Serie C","soccer","bra.3"),
5345  ( 373,1,"Copa Do Nordeste","soccer","bra.copa_do_nordeste"),
5346  ( 374,1,"Brazilian Campeonato Carioca","soccer","bra.camp.carioca"),
5347  ( 375,1,"Brazilian Campeonato Paulista","soccer","bra.camp.paulista"),
5348  ( 376,1,"Brazilian Campeonato Gaucho","soccer","bra.camp.gaucho"),
5349  ( 377,1,"Brazilian Campeonato Mineiro","soccer","bra.camp.mineiro"),
5350  ( 378,1,"Chilean Primera División","soccer","chi.1"),
5351  ( 379,1,"Copa Chile","soccer","chi.copa_chi"),
5352  ( 380,1,"International U20 Friendly","soccer","fifa.u20.friendly"),
5353  ( 381,1,"Segunda División de Chile","soccer","chi.2"),
5354  ( 382,1,"Chilean Supercopa","soccer","chi.super_cup"),
5355  ( 383,1,"Uruguayan Primera Division","soccer","uru.1"),
5356  ( 384,1,"Segunda División de Uruguay","soccer","uru.2"),
5357  ( 385,1,"Colombian SuperLiga","soccer","col.superliga"),
5358  ( 386,1,"Colombian Primera A","soccer","col.1"),
5359  ( 387,1,"Colombian Primera B","soccer","col.2"),
5360  ( 388,1,"Peruvian Supercopa","soccer","per.supercopa"),
5361  ( 389,1,"Copa Colombia","soccer","col.copa"),
5362  ( 390,1,"Peruvian Primera Profesional","soccer","per.1"),
5363  ( 391,1,"Paraguayan Primera Division","soccer","par.1"),
5364  ( 392,1,"Ecuadoran Primera A","soccer","ecu.1"),
5365  ( 393,1,"Ecuadoran Supercopa","soccer","ecu.supercopa"),
5366  ( 394,1,"Ecuador Serie B","soccer","ecu.2"),
5367  ( 395,1,"Venezuelan Primera Profesional","soccer","ven.1"),
5368  ( 396,1,"United States NWSL Challenge Cup","soccer","usa.nwsl.cup"),
5369  ( 397,1,"Segunda División de Venezuela","soccer","ven.2"),
5370  ( 398,1,"Bolivian Liga Profesional","soccer","bol.1"),
5371  ( 399,1,"Mexican Supercopa MX","soccer","mex.supercopa"),
5372  ( 400,1,"Mexican Campeon de Campeones","soccer","mex.campeon"),
5373  ( 401,1,"CONCACAF Champions Cup","soccer","concacaf.champions_cup"),
5374  ( 402,1,"CONCACAF U23 Tournament","soccer","concacaf.u23"),
5375  ( 403,1,"Honduran Primera Division","soccer","hon.1"),
5376  ( 404,1,"Costa Rican Primera Division","soccer","crc.1"),
5377  ( 405,1,"Jamaican Premier League","soccer","jam.1"),
5378  ( 406,1,"Guatemalan Liga Nacional","soccer","gua.1"),
5379  ( 407,1,"Australian W-League","soccer","aus.w.1"),
5380  ( 408,1,"Salvadoran Primera Division","soccer","slv.1"),
5381  ( 409,1,"AFF Cup","soccer","aff.championship"),
5382  ( 410,1,"AFC Cup","soccer","afc.cup"),
5383  ( 411,1,"SAFF Championship","soccer","afc.saff.championship"),
5384  ( 412,1,"Chinese Super League Promotion/Relegation Playoffs","soccer","chn.1.promotion.relegation"),
5385  ( 413,1,"Japanese J League","soccer","jpn.1"),
5386  ( 414,1,"Indonesian Liga 1","soccer","idn.1"),
5387  ( 415,1,"Indian Super League","soccer","ind.1"),
5388  ( 416,1,"Indian I-League","soccer","ind.2"),
5389  ( 417,1,"Malaysian Super League","soccer","mys.1"),
5390  ( 418,1,"Singaporean Premier League","soccer","sgp.1"),
5391  ( 419,1,"Thai League 1","soccer","tha.1"),
5392  ( 420,1,"Bangabandhu Cup","soccer","bangabandhu.cup"),
5393  ( 421,1,"COSAFA Cup","soccer","caf.cosafa"),
5394  ( 422,1,"CAF Champions League","soccer","caf.champions"),
5395  ( 423,1,"South African Premiership Promotion/Relegation Playoffs","soccer","rsa.1.promotion.relegation"),
5396  ( 424,1,"CAF Confederations Cup","soccer","caf.confed"),
5397  ( 425,1,"South African Premiership","soccer","rsa.1"),
5398  ( 426,1,"South African First Division","soccer","rsa.2"),
5399  ( 427,1,"South African Telkom Knockout","soccer","rsa.telkom_knockout"),
5400  ( 428,1,"South African Nedbank Cup","soccer","rsa.nedbank"),
5401  ( 429,1,"MTN 8 Cup","soccer","rsa.mtn8"),
5402  ( 430,1,"Nigerian Professional League","soccer","nga.1"),
5403  ( 431,1,"Ghanaian Premier League","soccer","gha.1"),
5404  ( 432,1,"Zambian Super League","soccer","zam.1"),
5405  ( 433,1,"Kenyan Premier League","soccer","ken.1"),
5406  ( 434,1,"Zimbabwean Premier Soccer League","soccer","zim.1"),
5407  ( 435,1,"Ugandan Premier League","soccer","uga.1"),
5408  ( 436,1,"Misc. U.S. Soccer Games","soccer","generic.ussf");)",
5409 
5410  R"(INSERT INTO sportsapi
5411  VALUES
5412  (1000,2,"Major League Baseball","baseball","mlb");)",
5413 
5414  R"(CREATE TABLE sportslisting (
5415  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
5416  api INT UNSIGNED NOT NULL,
5417  title VARCHAR(128) NOT NULL
5418  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;)",
5419 
5420  R"(INSERT INTO sportslisting (api,title)
5421  VALUES
5422  ( 1, "\\A(?:MLB Baseball)\\z"),
5423  ( 1, "\\A(?:Béisbol MLB)\\z"),
5424  ( 1, "\\A(?:MLB All-Star Game)\\z"),
5425  ( 1, "\\A(?:World Series)\\z"),
5426  ( 2, "\\A(?:College Baseball)\\z"),
5427  ( 2, "\\A(?:College World Series)\\z"),
5428  ( 3, "\\A(?:College Softball)\\z"),
5429  ( 4, "\\A(?:Women's College World Series)\\z"),
5430  ( 10, "\\A(?:Béisbol Liga Mexicana)\\z"),
5431 
5432  ( 20, "\\A(?:N\\w+ Football)\\z"),
5433  ( 20, "\\A(?:Super Bowl( [CLXVI]+)?)\\z"),
5434  ( 20, "\\A(?:Fútbol Americano NFL)\\z"),
5435  ( 21, "\\A(?:College Football)\\z"),
5436  ( 21, "\\A(?:\\w+ Bowl)\\z"),
5437  ( 21, "\\A(?:Fútbol Americano de Universitario)\\z"),
5438 
5439  ( 40, "\\A(?:NBA Basketball)\\z"),
5440  ( 40, "\\A(?:NBA Finals)\\z"),
5441  ( 41, "\\A(?:WNBA Basketball)\\z"),
5442  ( 41, "\\A(?:WNBA Finals)\\z"),
5443  ( 42, "\\A(?:College Basketball)\\z"),
5444  ( 42, "\\A(?:NCAA Basketball Tournament)\\z"),
5445  ( 43, "\\A(?:Women's College Basketball)\\z"),
5446  ( 43, "\\A(?:NCAA Women's Basketball Tournament)\\z"),
5447 
5448  ( 60, "\\A(?:NHL Hockey)\\z"),
5449  ( 60, "\\A(?:NHL Winter Classic)\\z"),
5450  ( 60, "\\A(?:NHL \\w+ Conference Final)\\z"),
5451  ( 60, "\\A(?:Stanley Cup Finals)\\z"),
5452  ( 61, "\\A(?:College Hockey)\\z"),
5453  ( 61, "\\A(?:Frozen Four)\\z"),
5454  ( 62, "\\A(?:Women's College Hockey)\\z"),
5455  ( 66, "\\A(?:College Field Hockey)\\z"),
5456 
5457  ( 80, "\\A(?:College Volleyball)\\z"),
5458  ( 81, "\\A(?:Women's College Volleyball)\\z"),
5459 
5460  ( 100, "\\A(?:College Lacrosse)\\z"),
5461  ( 101, "\\A(?:Women's College Lacrosse)\\z"),
5462 
5463  ( 120, "\\A(?:College Water Polo)\\z"),
5464  ( 121, "\\A(?:Women's College Water Polo)\\z"),
5465 
5466  ( 200, "\\A(?:College Soccer)\\z"),
5467  ( 201, "\\A(?:Women's College Soccer)\\z"),
5468  ( 202, "\\A(?:MLS Soccer|Fútbol MLS)\\z"),
5469  ( 203, "\\A(?:(Premier League|EPL) Soccer)\\z"),
5470  ( 203, "\\A(?:English Premier League)\\z"),
5471  ( 203, "\\A(?:Fútbol Premier League)\\z"),
5472  ( 205, "\\A(?:Italian Serie A Soccer)\\z"),
5473  ( 339, "\\A(?:Italian Serie B Soccer)\\z"),
5474  ( 206, "\\A(?:French Ligue 1 Soccer|Fútbol Ligue 1|Fútbol Liga 1)\\z"),
5475  ( 207, "\\A(?:French Ligue 2 Soccer|Fútbol Ligue 2|Fútbol Liga 2)\\z"),
5476  ( 208, "\\A(?:Fútbol LaLiga)\\z"),
5477  ( 208, "\\A(?:Fútbol Español Primera Division)\\z"),
5478  ( 208, "\\A(?:Spanish Primera Division Soccer)\\z"),
5479  ( 209, "\\A(?:(German )?Bundesliga Soccer)\\z"),
5480  ( 209, "\\A(?:Fútbol Bundesliga)\\z"),
5481  ( 209, "\\A(?:Fútbol Copa de Alemania)\\z"),
5482  ( 210, "\\A(?:German 2. Bundesliga Soccer)\\z"),
5483  ( 211, "\\A(?:Fútbol Mexicano Primera División|Fútbol Mexicano Liga Premier|Fútbol Mexicano)\\z"),
5484  ( 211, "\\A(?:Mexico Primera Division Soccer)\\z"),
5485  ( 212, "\\A(?:Copa do Brazil Soccer)\\z"),
5486  ( 214, "\\A(?:CONCACAF League Soccer)\\z"),
5487  ( 215, "\\A(?:CONCACAF Champions League Soccer)\\z"),
5488  ( 216, "\\A(?:CONCACAF Nations League Soccer)\\z"),
5489  ( 217, "\\A(?:CONCACAF Gold Cup Soccer)\\z"),
5490  ( 218, "\\A(?:FIFA World Cup Soccer)\\z"),
5491  ( 219, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5492  ( 220, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5493  ( 221, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5494  ( 222, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5495  ( 223, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5496  ( 224, "\\A(?:FIFA World Cup Qualifying( Soccer)?|FIFA Eliminatorias Copa Mundial)\\z"),
5497  ( 225, "\\A(?:Fútbol UEFA Champions League)\\z"),
5498  ( 225, "\\A(?:UEFA Champions League Soccer)\\z"),
5499  ( 226, "\\A(?:Fútbol UEFA Europa League)\\z"),
5500  ( 229, "\\A(?:Fútbol USL Championship)\\z"),
5501  ( 229, "\\A(?:USL Championship Soccer)\\z"),
5502  ( 230, "\\A(?:NWSL Soccer)\\z"),
5503  ( 231, "\\A(?:FA Women's Super League)\\z"),
5504  ( 242, "\\A(?:Fútbol Mexicano Liga Expansión)\\z"),
5505  ( 258, "\\A(?:UEFA Nations League Soccer)\\z"),
5506  ( 258, "\\A(?:Fútbol UEFA Nations League)\\z"),
5507  ( 271, "\\A(?:Fútbol Español Segunda Division)\\z"),
5508  ( 277, "\\A(?:Fútbol Turco Superliga)\\z"),
5509  ( 277, "\\A(?:Turkish Super Lig Soccer)\\z"),
5510  ( 279, "\\A(?:Superleague Greek Soccer)\\z"),
5511  ( 356, "\\A(?:Fútbol CONMEBOL Libertadores)\\z"),
5512  ( 357, "\\A(?:Fútbol CONMEBOL Sudamericana)\\z"),
5513  ( 359, "\\A(?:Fútbol Argentino Primera División)\\z"),
5514  ( 360, "\\A(?:Fútbol Copa Argentina)\\z"),
5515  ( 365, "\\A(?:Fútbol Argentino Primera Nacional( B)?)\\z"),
5516  ( 366, "\\A(?:Fútbol Argentino Primera B)\\z"),
5517  ( 367, "\\A(?:Fútbol Argentino Primera C)\\z"),
5518  ( 368, "\\A(?:Fútbol Argentino Primera D)\\z"),
5519  ( 386, "\\A(?:Fútbol Columbiano Primera División)\\z"),
5520  ( 403, "\\A(?:Fútbol Hondureño Primera División)\\z"),
5521  ( 404, "\\A(?:Fútbol Costarricense Primera División)\\z"),
5522 
5523  (1000, "\\A(?:MLB Baseball)\\z"),
5524  (1000, "\\A(?:Béisbol MLB)\\z");
5525  )",
5526 
5527  R"(CREATE TABLE sportscleanup (
5528  id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
5529  provider TINYINT UNSIGNED DEFAULT 0,
5530  weight INT UNSIGNED NOT NULL,
5531  key1 VARCHAR(256) NOT NULL,
5532  name VARCHAR(256) NOT NULL,
5533  pattern VARCHAR(256) NOT NULL,
5534  nth TINYINT UNSIGNED NOT NULL,
5535  replacement VARCHAR(128) NOT NULL
5536  ) ENGINE=MyISAM DEFAULT CHARSET=utf8;)",
5537 
5538  // Sigh. It would be nice if these patterns could use the
5539  // '\b' boundary matching sequence in the first part of
5540  // the match, but the period is not part of the set of
5541  // characters that make up a word, so trying to optionally
5542  // match the final period in the string "F.C. Foo" with
5543  // the pattern "\.?\b" always fails because period and
5544  // space are both non-word characters and therefore there
5545  // is no word boundary between them. This will always
5546  // match on "F.C" and never on "F.C.".
5547  //
5548  // I have also seen a TV listing where the team name was
5549  // "F.C.Something" without a space, so the first part of
5550  // these patterns doesn't require a following space in
5551  // order to match. These patterns are case sensitive, so
5552  // the first part shouldn't match part of an ordinary team
5553  // name unless the team name is in all caps.
5554  R"A(INSERT INTO sportscleanup (provider,weight,key1,name,pattern,nth,replacement)
5555  VALUES
5556  (1,1000,"soccer", "(SE)", "\\(\\w+\\)", 0, ""),
5557  (1,1000,"soccer", "AFC", "\\AA\\.?F\\.?C\\.?|\\bA\\.?F\\.?C\\.?\\Z", 0, ""),
5558  (1,1000,"soccer", "AC etc.", "\\AA\\.?[AC]\\.?|\\bA\\.?[AC]\\.?\\Z", 0, ""),
5559  (1,1000,"soccer", "BK", "\\AB\\.?K\\.?|\\bB\\.?K\\.?\\Z", 0, ""),
5560  (1,1000,"soccer", "BSC", "\\AB\\.?S\\.?C\\.?|\\bB\\.?S\\.?C\\.?\\Z", 0, ""),
5561  (1,1000,"soccer", "CSyD", "\\AC\\.?S\\.?( y )?D\\.?|\\bC\\.?S\\.?( y )?D\\.?\\Z", 0, ""),
5562  (1,1000,"soccer", "CD etc.", "\\AC\\.?[ADFRS]\\.?|\\bC\\.?[ADFRS]\\.?\\Z", 0, ""),
5563  (1,1000,"soccer", "FC", "\\AF\\.?C\\.?|\\bF\\.?C\\.?\\Z", 0, ""),
5564  (1,1000,"soccer", "HSC", "\\AH\\.?S\\.?C\\.?|\\bH\\.?S\\.?C\\.?\\Z", 0, ""),
5565  (1,1000,"soccer", "RC etc.", "\\AR\\.?[BC]\\.?|\\bR\\.?[BC]\\.?\\Z", 0, ""),
5566  (1,1000,"soccer", "SC etc.", "\\AS\\.?[ACV]\\.?|\\bS\\.?[ACV]\\.?\\Z", 0, ""),
5567  (1,1000,"soccer", "TSG", "\\AT\\.?S\\.?G\\.?|\\bT\\.?S\\.?G\\.?\\Z", 0, ""),
5568  (1,1000,"soccer", "VFB etc.", "\\AV\\.?F\\.?[BL]\\.?|\\bV\\.?F\\.?[BL]\\.?\\Z", 0, ""),
5569  (1,2000,"all", "", "Inglaterra", 0, "England"),
5570  (1,2000,"all", "", "Munchen", 0, "Munich");
5571  )A",
5572  };
5573  case 2:
5574  return {
5575  // More TV listing name to API name mappings for college
5576  // basketball. Using a weight of 1000 for specific
5577  // changes and 1100 for general changes.
5578  R"A(INSERT INTO sportscleanup (provider,weight,key1,name,pattern,nth,replacement)
5579  VALUES
5580  (1,1100,"basketball", "Cal State", "Cal State", 0, "CSU"),
5581  (1,1000,"basketball", "Grambling", "Grambling State", 0, "Grambling"),
5582  (1,1000,"basketball", "Hawaii", "Hawaii", 0, "Hawai'i"),
5583  (1,1000,"basketball", "LIU", "LIU", 0, "Long Island University"),
5584  (1,1100,"basketball", "Loyola", "Loyola-", 0, "Loyola "),
5585  (1,1000,"basketball", "Loyola (Md.)", "Loyola \(Md.\)", 0, "Loyola (MD)"),
5586  (1,1000,"basketball", "McNeese", "McNeese State", 0, "McNeese"),
5587  (1,1000,"basketball", "Miami (OH)", "Miami \(Ohio\)", 0, "Miami (OH)"),
5588  (1,1000,"basketball", "UAB", "Alabama-Birmingham", 0, "UAB"),
5589  (1,1000,"basketball", "UConn", "Connecticut", 0, "UConn"),
5590  (1,1000,"basketball", "UMass", "Massachusetts", 0, "UMass"),
5591  (1,1100,"basketball", "UNC", "UNC-", 0, "UNC "),
5592  (1,1000,"basketball", "UTEP", "Texas-El Paso", 0, "UTEP"),
5593  (1,1100,"basketball", "Texas", "Texas-", 0, "UT "),
5594  (1,1000,"basketball", "Chattanooga", "UT-Chattanooga", 0, "Chattanooga"),
5595  (1,1100,"basketball", "UT", "UT-", 0, "UT ");
5596  )A",
5597  };
5598 
5599  default:
5600  return {};
5601  }
5602 }
5603 
5604 /* vim: set expandtab tabstop=4 shiftwidth=4: */
5605 
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:807
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:912
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:608
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:3955
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:540
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:79
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:883
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:832