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:
2026-06-11 16:02:17 -04:00
parent f00acbc280
commit 0974ab2b4c
4 changed files with 91 additions and 57 deletions
+7 -1
View File
@@ -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)