You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
5.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. error_reporting( E_ALL );
  3. require_once('settings.php');
  4. require_once('defines.php');
  5. $UPGRADE = false;
  6. $TT_123 = explode( '.', PHP_VERSION );
  7. if( $TT_123[0] == '4' ){
  8. require_once( 'php/db/MySQL_class.php' );
  9. $DATABASE = new MySQL_DB($DBHost, $DBName, $DBUser, $DBPassword);
  10. } elseif( $TT_123[0] > '4' ){
  11. require_once( 'php/db/MySQLi_class.php' );
  12. $DATABASE = new MySQLi_DB($DBHost, $DBName, $DBUser, $DBPassword);
  13. } else {
  14. echo "CANNOT DETERMINE DATABASE ENGINE!!!!!!!\n\n";
  15. exit();
  16. };
  17. $QS="SHOW INDEX FROM `modbus_modules` WHERE Column_name='platform_id'";
  18. $R = $DATABASE->Query( $QS );
  19. if( count( $R ) ){
  20. $QS = "ALTER TABLE `modbus_modules` DROP INDEX `{$R[0]['Key_name']}`";
  21. $UPGRADE = true;
  22. $DATABASE->Query( $QS );
  23. };
  24. $QS = "SHOW COLUMNS FROM `modbus_modules` LIKE 'label'";
  25. $R = $DATABASE->Query( $QS );
  26. if( count( $R ) == 0 ){
  27. $QS = "ALTER TABLE `modbus_modules` ADD `label` CHAR(32) DEFAULT ''";
  28. $UPGRADE = true;
  29. $DATABASE->Query( $QS );
  30. };
  31. $QS = "SHOW COLUMNS FROM `metro_stations` LIKE 'short'";
  32. $R = $DATABASE->Query( $QS );
  33. if( count( $R ) == 0 ){
  34. $QS = "ALTER TABLE `metro_stations` ADD `short` CHAR(32) DEFAULT ''";
  35. $UPGRADE = true;
  36. $DATABASE->Query( $QS );
  37. };
  38. $QS = "SHOW TABLES LIKE 'session_composer_queue'";
  39. $R = $DATABASE->Query( $QS );
  40. if( count( $R ) ){
  41. $QS = "ALTER TABLE `session_composer_queue` RENAME TO `media_composer_queue`";
  42. $UPGRADE = true;
  43. $DATABASE->Query( $QS );
  44. };
  45. $QS = "SHOW TABLES LIKE 'media_composer_queue'";
  46. $R = $DATABASE->Query( $QS );
  47. if( count( $R ) == 0 ){
  48. $QS =<<<DATA_BOUNDARY
  49. CREATE TABLE `argus`.`media_composer_queue` (
  50. `id` int UNSIGNED NOT NULL AUTO_INCREMENT,
  51. `ts` int UNSIGNED NOT NULL,
  52. `session_id` int UNSIGNED NOT NULL,
  53. `uuid` char(64) NOT NULL,
  54. `status` char(1) CHARACTER SET ascii COLLATE ascii_bin NULL DEFAULT 'N',
  55. `process` tinyint(3) UNSIGNED NULL DEFAULT 0,
  56. PRIMARY KEY (`id`)
  57. ) ENGINE = MyISAM;
  58. DATA_BOUNDARY;
  59. $UPGRADE = true;
  60. $DATABASE->Query( $QS );
  61. };
  62. $QS = "SHOW TABLES LIKE 'media_encoder_queue'";
  63. $R = $DATABASE->Query( $QS );
  64. if( count( $R ) == 0 ){
  65. $QS = "ALTER TABLE `media_queue` RENAME TO `media_encoder_queue`";
  66. $UPGRADE = true;
  67. $DATABASE->Query( $QS );
  68. };
  69. $QS = "SELECT * FROM `session_statuses` WHERE `lvl`=1";
  70. $R = $DATABASE->Query( $QS );
  71. if( count( $R ) == 0 ){
  72. $QS = "INSERT INTO `session_statuses`(`lvl`,`label`,`min_access`,`class`) VALUES(1,'Dismiss by Station',3,'active_yellow')";
  73. $DATABASE->Query( $QS );
  74. };
  75. $QS = "SHOW COLUMNS FROM `metro_platforms` LIKE 'left_side'";
  76. $R = $DATABASE->Query( $QS );
  77. if( count( $R ) == 0 ){
  78. $QS = "ALTER TABLE `metro_platforms` ADD `left_side` CHAR(16) DEFAULT ''";
  79. $DATABASE->Query( $QS );
  80. $UPGRADE = true;
  81. };
  82. $QS = "SHOW COLUMNS FROM `metro_platforms` LIKE 'right_side'";
  83. $R = $DATABASE->Query( $QS );
  84. if( count( $R ) == 0 ){
  85. $QS = "ALTER TABLE `metro_platforms` ADD `right_side` CHAR(16) DEFAULT ''";
  86. $DATABASE->Query( $QS );
  87. $UPGRADE = true;
  88. };
  89. $QS = "SHOW COLUMNS FROM `modbus_modules` LIKE 'func'";
  90. $R = $DATABASE->Query( $QS );
  91. if( count( $R ) == 0 ){
  92. $QS = "ALTER TABLE `modbus_modules` DROP COLUMN `label`";
  93. $DATABASE->Query( $QS );
  94. $QS = "ALTER TABLE `modbus_modules` ADD `func` TINYINT(3) UNSIGNED DEFAULT 0";
  95. $DATABASE->Query( $QS );
  96. $UPGRADE = true;
  97. };
  98. $QS = "SHOW TABLES LIKE 'metro_platforms_mboxes'";
  99. $R = $DATABASE->Query( $QS );
  100. if( count( $R ) == 0 ){
  101. $QS =<<<DATA_BOUNDARY
  102. CREATE TABLE `metro_platforms_mboxes` (
  103. `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  104. `platform_id` int(10) UNSIGNED NOT NULL,
  105. `type` tinyint(3) NOT NULL,
  106. `src` int(10) UNSIGNED DEFAULT 0,
  107. `ts` int(10) UNSIGNED NOT NULL,
  108. `status` tinyint(3) UNSIGNED NULL DEFAULT 0,
  109. `value` char(32) CHARACTER SET ascii COLLATE ascii_bin NULL DEFAULT '0',
  110. `msg` char(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '',
  111. PRIMARY KEY (`id`) USING BTREE,
  112. UNIQUE INDEX `uniq`(`platform_id`, `type`, `src`) USING BTREE
  113. ) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Fixed;
  114. DATA_BOUNDARY;
  115. $UPGRADE = true;
  116. $DATABASE->Query( $QS );
  117. } else {
  118. $QS = "SHOW COLUMNS FROM `metro_platforms_mboxes` LIKE 'src'";
  119. $R = $DATABASE->Query( $QS );
  120. if( count( $R ) == 0 ){
  121. $UPGRADE = true;
  122. $QS = "ALTER TABLE `metro_platforms_mboxes` ADD `src` INT(10) UNSIGNED DEFAULT 0";
  123. $DATABASE->Query( $QS );
  124. $QS = "ALTER TABLE `metro_platforms_mboxes` DROP INDEX `uniq`";
  125. $DATABASE->Query( $QS );
  126. $QS = "ALTER TABLE `metro_platforms_mboxes` ADD UNIQUE INDEX `uniq`(`platform_id`, `type`, `src`) USING BTREE";
  127. $DATABASE->Query( $QS );
  128. };
  129. };
  130. $QS = "SHOW COLUMNS FROM `system_props` LIKE 'modbus_auto_supress'";
  131. $R = $DATABASE->Query( $QS );
  132. if( count( $R ) == 0 ){
  133. $QS = "ALTER TABLE `system_props` ADD `modbus_auto_supress` TINYINT(3) UNSIGNED DEFAULT 0";
  134. $DATABASE->Query( $QS );
  135. $UPGRADE = true;
  136. };
  137. if( $UPGRADE ){
  138. echo "Upgrade Done!\n\n";
  139. } else {
  140. echo "No Upgrade Needed!\n\n";
  141. };
  142. ?>