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