refactor(store): schema_version migration table + DeleteAlert FK fix
Replace the error-string-matching migration runner with a proper schema_version table. Migrations are now numbered and recorded; only unapplied versions run. Fresh databases seed at baseline version (CREATE TABLE already includes all columns). CREATE TABLE statements updated to include regions (sites) and node_id (check_history) — previously only added via ALTER. DeleteAlert now nulls sites.alert_id before deleting, preventing dangling references that caused every incident to hit the error path instead of alerting.
This commit is contained in:
@@ -5,10 +5,16 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Migration struct {
|
||||
Version int
|
||||
SQL string
|
||||
}
|
||||
|
||||
type Dialect interface {
|
||||
DriverName() string
|
||||
CreateTablesSQL() []string
|
||||
MigrationsSQL() []string
|
||||
Migrations() []Migration
|
||||
BaselineVersion() int
|
||||
BoolFalse() string
|
||||
ResetSequenceOnEmpty(db *sql.DB, table string)
|
||||
ImportWipe(tx *sql.Tx)
|
||||
|
||||
Reference in New Issue
Block a user