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