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.
 
 
 
 

149 lines
5.1 KiB

<?php
error_reporting( E_ALL );
require_once('settings.php');
require_once('defines.php');
$UPGRADE = false;
$TT_123 = explode( '.', PHP_VERSION );
if( $TT_123[0] == '4' ){
require_once( 'php/db/MySQL_class.php' );
$DATABASE = new MySQL_DB($DBHost, $DBName, $DBUser, $DBPassword);
} elseif( $TT_123[0] > '4' ){
require_once( 'php/db/MySQLi_class.php' );
$DATABASE = new MySQLi_DB($DBHost, $DBName, $DBUser, $DBPassword);
} else {
echo "CANNOT DETERMINE DATABASE ENGINE!!!!!!!\n\n";
exit();
};
$QS="SHOW INDEX FROM `modbus_modules` WHERE Column_name='platform_id'";
$R = $DATABASE->Query( $QS );
if( count( $R ) ){
$QS = "ALTER TABLE `modbus_modules` DROP INDEX `{$R[0]['Key_name']}`";
$UPGRADE = true;
$DATABASE->Query( $QS );
};
$QS = "SHOW COLUMNS FROM `modbus_modules` LIKE 'label'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "ALTER TABLE `modbus_modules` ADD `label` CHAR(32) DEFAULT ''";
$UPGRADE = true;
$DATABASE->Query( $QS );
};
$QS = "SHOW COLUMNS FROM `metro_stations` LIKE 'short'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "ALTER TABLE `metro_stations` ADD `short` CHAR(32) DEFAULT ''";
$UPGRADE = true;
$DATABASE->Query( $QS );
};
$QS = "SHOW TABLES LIKE 'session_composer_queue'";
$R = $DATABASE->Query( $QS );
if( count( $R ) ){
$QS = "ALTER TABLE `session_composer_queue` RENAME TO `media_composer_queue`";
$UPGRADE = true;
$DATABASE->Query( $QS );
};
$QS = "SHOW TABLES LIKE 'media_composer_queue'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS =<<<DATA_BOUNDARY
CREATE TABLE `argus`.`media_composer_queue` (
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
`ts` int UNSIGNED NOT NULL,
`session_id` int UNSIGNED NOT NULL,
`uuid` char(64) NOT NULL,
`status` char(1) CHARACTER SET ascii COLLATE ascii_bin NULL DEFAULT 'N',
`process` tinyint(3) UNSIGNED NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE = MyISAM;
DATA_BOUNDARY;
$UPGRADE = true;
$DATABASE->Query( $QS );
};
$QS = "SHOW TABLES LIKE 'media_encoder_queue'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "ALTER TABLE `media_queue` RENAME TO `media_encoder_queue`";
$UPGRADE = true;
$DATABASE->Query( $QS );
};
$QS = "SELECT * FROM `session_statuses` WHERE `lvl`=1";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "INSERT INTO `session_statuses`(`lvl`,`label`,`min_access`,`class`) VALUES(1,'Dismiss by Station',3,'active_yellow')";
$DATABASE->Query( $QS );
};
$QS = "SHOW COLUMNS FROM `metro_platforms` LIKE 'left_side'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "ALTER TABLE `metro_platforms` ADD `left_side` CHAR(16) DEFAULT ''";
$DATABASE->Query( $QS );
$UPGRADE = true;
};
$QS = "SHOW COLUMNS FROM `metro_platforms` LIKE 'right_side'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "ALTER TABLE `metro_platforms` ADD `right_side` CHAR(16) DEFAULT ''";
$DATABASE->Query( $QS );
$UPGRADE = true;
};
$QS = "SHOW COLUMNS FROM `modbus_modules` LIKE 'func'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "ALTER TABLE `modbus_modules` DROP COLUMN `label`";
$DATABASE->Query( $QS );
$QS = "ALTER TABLE `modbus_modules` ADD `func` TINYINT(3) UNSIGNED DEFAULT 0";
$DATABASE->Query( $QS );
$UPGRADE = true;
};
$QS = "SHOW TABLES LIKE 'metro_platforms_mboxes'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS =<<<DATA_BOUNDARY
CREATE TABLE `metro_platforms_mboxes` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`platform_id` int(10) UNSIGNED NOT NULL,
`type` tinyint(3) NOT NULL,
`src` int(10) UNSIGNED DEFAULT 0,
`ts` int(10) UNSIGNED NOT NULL,
`status` tinyint(3) UNSIGNED NULL DEFAULT 0,
`value` char(32) CHARACTER SET ascii COLLATE ascii_bin NULL DEFAULT '0',
`msg` char(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `uniq`(`platform_id`, `type`, `src`) USING BTREE
) ENGINE = MyISAM AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Fixed;
DATA_BOUNDARY;
$UPGRADE = true;
$DATABASE->Query( $QS );
} else {
$QS = "SHOW COLUMNS FROM `metro_platforms_mboxes` LIKE 'src'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$UPGRADE = true;
$QS = "ALTER TABLE `metro_platforms_mboxes` ADD `src` INT(10) UNSIGNED DEFAULT 0";
$DATABASE->Query( $QS );
$QS = "ALTER TABLE `metro_platforms_mboxes` DROP INDEX `uniq`";
$DATABASE->Query( $QS );
$QS = "ALTER TABLE `metro_platforms_mboxes` ADD UNIQUE INDEX `uniq`(`platform_id`, `type`, `src`) USING BTREE";
$DATABASE->Query( $QS );
};
};
$QS = "SHOW COLUMNS FROM `system_props` LIKE 'modbus_auto_supress'";
$R = $DATABASE->Query( $QS );
if( count( $R ) == 0 ){
$QS = "ALTER TABLE `system_props` ADD `modbus_auto_supress` TINYINT(3) UNSIGNED DEFAULT 0";
$DATABASE->Query( $QS );
$UPGRADE = true;
};
if( $UPGRADE ){
echo "Upgrade Done!\n\n";
} else {
echo "No Upgrade Needed!\n\n";
};
?>