实现数据库级联删除
All checks were successful
Go CI / test-and-build (push) Successful in 10s

This commit is contained in:
2026-04-06 16:32:10 +08:00
parent 744fa578f1
commit 3aa8057648
5 changed files with 189 additions and 14 deletions

6
db.go
View File

@@ -31,6 +31,12 @@ func InitDB(dbPath string) error {
return fmt.Errorf("failed to open database: %v", err)
}
// Enable foreign key support in SQLite
_, err = DB.Exec("PRAGMA foreign_keys = ON")
if err != nil {
return fmt.Errorf("failed to enable foreign keys: %v", err)
}
if err = DB.Ping(); err != nil {
return fmt.Errorf("failed to ping database: %v", err)
}