mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-04 09:11:34 -07:00
Refactor event and session column names to camelCase
- Updated test cases to reflect new column names (eve_MAC -> eveMac, eve_DateTime -> eveDateTime, etc.) across various test files. - Modified SQL table definitions in the database cleanup and migration tests to use camelCase naming conventions. - Implemented migration tests to ensure legacy column names are correctly renamed to camelCase equivalents. - Ensured that existing data is preserved during the migration process and that views referencing old column names are dropped before renaming. - Verified that the migration function is idempotent, allowing for safe re-execution without data loss.
This commit is contained in:
@@ -581,8 +581,8 @@ def print_scan_stats(db):
|
||||
row_dict = dict(row)
|
||||
mylog("trace", f" {row_dict}")
|
||||
|
||||
mylog("trace", " ================ Events table content where eve_PendingAlertEmail = 1 ================",)
|
||||
sql.execute("select * from Events where eve_PendingAlertEmail = 1")
|
||||
mylog("trace", " ================ Events table content where evePendingAlertEmail = 1 ================",)
|
||||
sql.execute("select * from Events where evePendingAlertEmail = 1")
|
||||
rows = sql.fetchall()
|
||||
for row in rows:
|
||||
row_dict = dict(row)
|
||||
@@ -611,9 +611,9 @@ def create_new_devices(db):
|
||||
mylog("debug", '[New Devices] Insert "New Device" Events')
|
||||
query_new_device_events = f"""
|
||||
INSERT OR IGNORE INTO Events (
|
||||
eve_MAC, eve_IP, eve_DateTime,
|
||||
eve_EventType, eve_AdditionalInfo,
|
||||
eve_PendingAlertEmail
|
||||
eveMac, eveIp, eveDateTime,
|
||||
eveEventType, eveAdditionalInfo,
|
||||
evePendingAlertEmail
|
||||
)
|
||||
SELECT DISTINCT scanMac, scanLastIP, '{startTime}', 'New Device', scanVendor, 1
|
||||
FROM CurrentScan
|
||||
@@ -630,9 +630,9 @@ def create_new_devices(db):
|
||||
mylog("debug", "[New Devices] Insert Connection into session table")
|
||||
|
||||
sql.execute(f"""INSERT INTO Sessions (
|
||||
ses_MAC, ses_IP, ses_EventTypeConnection, ses_DateTimeConnection,
|
||||
ses_EventTypeDisconnection, ses_DateTimeDisconnection,
|
||||
ses_StillConnected, ses_AdditionalInfo
|
||||
sesMac, sesIp, sesEventTypeConnection, sesDateTimeConnection,
|
||||
sesEventTypeDisconnection, sesDateTimeDisconnection,
|
||||
sesStillConnected, sesAdditionalInfo
|
||||
)
|
||||
SELECT scanMac, scanLastIP, 'Connected', '{startTime}', NULL, NULL, 1, scanVendor
|
||||
FROM CurrentScan
|
||||
@@ -642,7 +642,7 @@ def create_new_devices(db):
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM Sessions
|
||||
WHERE ses_MAC = scanMac AND ses_StillConnected = 1
|
||||
WHERE sesMac = scanMac AND sesStillConnected = 1
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user