refactor(db): replace cidr with ip column in audit_log table
Remove the cidr column from the audit_log table schema and update all INSERT statements to use the ip column instead, aligning the field name with the actual data being stored.
This commit is contained in:
7
db.go
7
db.go
@@ -42,7 +42,6 @@ func InitDB(dbPath string) (*sql.DB, error) {
|
||||
timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
action TEXT NOT NULL,
|
||||
ip TEXT,
|
||||
cidr TEXT,
|
||||
ttl_seconds INTEGER,
|
||||
reason TEXT,
|
||||
api_client_ip TEXT
|
||||
@@ -61,7 +60,7 @@ func AddPermanentEntry(db *sql.DB, entry, apiClientIP string) (bool, error) {
|
||||
if err != nil {
|
||||
if isUniqueConstraintError(err) {
|
||||
_, err = db.Exec(`
|
||||
INSERT INTO audit_log(action, cidr, api_client_ip)
|
||||
INSERT INTO audit_log(action, ip, api_client_ip)
|
||||
VALUES('add_perm_duplicate', ?, ?)
|
||||
`, entry, apiClientIP)
|
||||
if err != nil {
|
||||
@@ -72,7 +71,7 @@ func AddPermanentEntry(db *sql.DB, entry, apiClientIP string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
_, err = db.Exec(`
|
||||
INSERT INTO audit_log(action, cidr, api_client_ip)
|
||||
INSERT INTO audit_log(action, ip, api_client_ip)
|
||||
VALUES('add_perm', ?, ?)
|
||||
`, entry, apiClientIP)
|
||||
if err != nil {
|
||||
@@ -90,7 +89,7 @@ func DeletePermanentEntry(db *sql.DB, entry, apiClientIP string) error {
|
||||
return err
|
||||
}
|
||||
_, err = db.Exec(`
|
||||
INSERT INTO audit_log(action, cidr, api_client_ip)
|
||||
INSERT INTO audit_log(action, ip, api_client_ip)
|
||||
VALUES('delete_perm', ?, ?)
|
||||
`, entry, apiClientIP)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user