CREATE TABLE IF NOT EXISTS connection_history ( id INTEGER PRIMARY KEY AUTOINCREMENT, connection_id INTEGER NOT NULL REFERENCES connections(id) ON DELETE CASCADE, protocol TEXT NOT NULL, connected_at DATETIME DEFAULT CURRENT_TIMESTAMP, disconnected_at DATETIME, duration_secs INTEGER );