Jelajahi Sumber

update migration for support full mac in some tables

root 3 bulan lalu
induk
melakukan
8dfaa0c7aa

+ 2 - 2
docs/databases/mysql/en/create_db.sql

@@ -240,7 +240,7 @@ CREATE TABLE `group_list` (
 
 CREATE TABLE `mac_history` (
   `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
+  `mac` varchar(17) DEFAULT NULL,
   `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
   `device_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
@@ -333,7 +333,7 @@ CREATE TABLE `traffic_detail` (
 
 CREATE TABLE `unknown_mac` (
   `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
+  `mac` varchar(17) DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `device_id` int(11) DEFAULT NULL,
   `ts` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()

+ 2 - 2
docs/databases/mysql/ru/create_db.sql

@@ -240,7 +240,7 @@ CREATE TABLE `group_list` (
 
 CREATE TABLE `mac_history` (
   `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
+  `mac` varchar(17) DEFAULT NULL,
   `ts` DATETIME NOT NULL DEFAULT current_timestamp(),
   `device_id` bigint(20) UNSIGNED DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
@@ -333,7 +333,7 @@ CREATE TABLE `traffic_detail` (
 
 CREATE TABLE `unknown_mac` (
   `id` bigint(20) UNSIGNED NOT NULL,
-  `mac` varchar(12) DEFAULT NULL,
+  `mac` varchar(17) DEFAULT NULL,
   `port_id` bigint(20) UNSIGNED DEFAULT NULL,
   `device_id` int(11) DEFAULT NULL,
   `ts` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()

+ 9 - 0
install-eye.sh

@@ -1712,6 +1712,7 @@ backup_current_installation() {
     #   - html/log/ — если есть
     tar -czf "$BACKUP_FILE" \
         --exclude="docs" \
+        --exclude="netflow" \
         --exclude="scripts/log" \
         --exclude="scripts/log/*" \
         --exclude="html/log" \
@@ -1736,11 +1737,15 @@ eye_upgrade() {
     echo -e "${GREEN}===========================================${NC}"
     echo ""
 
+    systemctl stop eye-statd dhcp-log stat-sync syslog-stat
+
     check_root
     detect_distro
 
     backup_current_installation || {
         echo "CRITICAL: Backup failed. Aborting upgrade."
+    
+    systemctl start eye-statd dhcp-log stat-sync syslog-stat
         exit 1
     }
 
@@ -1748,7 +1753,11 @@ eye_upgrade() {
     install_packages
     install_source_code
     import_mac_database
+
     /opt/Eye/scripts/updates/upgrade.pl
+
+    systemctl start eye-statd dhcp-log stat-sync syslog-stat
+
     show_final_upgrade
 }
 

+ 10 - 0
scripts/updates/3-0-1/migration.msql

@@ -152,3 +152,13 @@ ALTER TABLE `ad_comp_cache`     MODIFY COLUMN `last_found` DATETIME NOT NULL DEF
 ALTER TABLE `devices`           MODIFY COLUMN `locked_timestamp` DATETIME NULL DEFAULT CURRENT_TIMESTAMP();
 ALTER TABLE `variables`         MODIFY COLUMN `clear_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(), MODIFY COLUMN `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP();
 
+-- migration mac to full
+
+-- 1. Обновляем mac_history
+ALTER TABLE `mac_history` MODIFY COLUMN `mac` VARCHAR(17) DEFAULT NULL;
+UPDATE `mac_history` SET mac = CONCAT( SUBSTRING(mac, 1, 2), ':', SUBSTRING(mac, 3, 2), ':', SUBSTRING(mac, 5, 2), ':', SUBSTRING(mac, 7, 2), ':', SUBSTRING(mac, 9, 2), ':', SUBSTRING(mac, 11, 2) ) WHERE mac IS NOT NULL AND LENGTH(mac) = 12;
+
+-- 2. Обновляем unknown_mac
+ALTER TABLE `unknown_mac` MODIFY COLUMN `mac` VARCHAR(17) DEFAULT NULL;
+UPDATE `unknown_mac` SET mac = CONCAT( SUBSTRING(mac, 1, 2), ':', SUBSTRING(mac, 3, 2), ':', SUBSTRING(mac, 5, 2), ':', SUBSTRING(mac, 7, 2), ':', SUBSTRING(mac, 9, 2), ':', SUBSTRING(mac, 11, 2) ) WHERE mac IS NOT NULL AND LENGTH(mac) = 12;
+