mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Final G9 step. The schema no longer creates current_room or room_seq_json on fresh installs, and existing prod schemas drop them via purgeLegacyZoneRunColumns() once the operator flips GOGOBEE_BRANCHING_PURGE=1. - CREATE TABLE dnd_zone_run loses both columns; comment updated to point at G1's columnMigrations for the graph-mode columns. - cleanup_g9.go mirrors the L5 idempotent-purge shape: ALTER TABLE DROP COLUMN per legacy column, "no such column" treated as already done, default-off. - Wired into adventure Init alongside purgeLegacyAdvCharacterTable. - Plan doc marks G9 complete. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
package plugin
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"strings"
|
|
|
|
"gogobee/internal/db"
|
|
)
|
|
|
|
// purgeLegacyZoneRunColumns drops the dnd_zone_run.current_room and
|
|
// dnd_zone_run.room_seq_json columns when the operator opts in via
|
|
// GOGOBEE_BRANCHING_PURGE=1. Phase G9 close-out: G9a removed the
|
|
// runtime gate, G9b stopped persisting the columns, and this is the
|
|
// final step.
|
|
//
|
|
// Idempotent: skips silently when the columns are already gone (or
|
|
// never existed on a fresh install — the schema in db.go no longer
|
|
// creates them).
|
|
func purgeLegacyZoneRunColumns() {
|
|
if os.Getenv("GOGOBEE_BRANCHING_PURGE") != "1" {
|
|
return
|
|
}
|
|
d := db.Get()
|
|
for _, col := range []string{"current_room", "room_seq_json"} {
|
|
if _, err := d.Exec("ALTER TABLE dnd_zone_run DROP COLUMN " + col); err != nil {
|
|
msg := err.Error()
|
|
// "no such column" → already dropped (or fresh install).
|
|
if strings.Contains(msg, "no such column") {
|
|
continue
|
|
}
|
|
slog.Error("G9 purge: drop column failed", "col", col, "err", err)
|
|
return
|
|
}
|
|
slog.Warn("G9 purge: dnd_zone_run column dropped (GOGOBEE_BRANCHING_PURGE=1)", "col", col)
|
|
}
|
|
}
|