This commit is contained in:
root
2026-10-01 22:16:48 +02:00
parent b6d1909d7f
commit 9dfdf79fa7
39 changed files with 4560 additions and 181 deletions
+13
View File
@@ -123,10 +123,23 @@ var schema = []string{
id {ID}, owner_id BIGINT NOT NULL REFERENCES players(id),
status TEXT NOT NULL, program {BLOB}, uplink {BLOB}, downlink {BLOB},
downlink_day BIGINT NOT NULL DEFAULT -1)`,
`CREATE TABLE IF NOT EXISTS downlinks (
ship_id BIGINT NOT NULL, day BIGINT NOT NULL, data {BLOB} NOT NULL,
PRIMARY KEY (ship_id, day))`,
// Downlinks kept before the history table existed: only the latest of each ship.
`INSERT INTO downlinks (ship_id, day, data)
SELECT id, downlink_day, downlink FROM ships WHERE downlink_day >= 0 AND downlink IS NOT NULL
ON CONFLICT (ship_id, day) DO NOTHING`,
`CREATE TABLE IF NOT EXISTS code_slots (
player_id BIGINT NOT NULL REFERENCES players(id), slot INTEGER NOT NULL,
name TEXT NOT NULL, source TEXT NOT NULL, updated_at TEXT NOT NULL,
PRIMARY KEY (player_id, slot))`,
`CREATE TABLE IF NOT EXISTS audit_log (
id {ID}, at BIGINT NOT NULL, player_id BIGINT NOT NULL, action TEXT NOT NULL,
ship_id BIGINT NOT NULL DEFAULT 0, slot INTEGER NOT NULL DEFAULT 0,
detail TEXT NOT NULL DEFAULT '', ip TEXT NOT NULL DEFAULT '')`,
`CREATE INDEX IF NOT EXISTS audit_player ON audit_log(player_id, id)`,
`CREATE INDEX IF NOT EXISTS audit_action ON audit_log(action, id)`,
`CREATE INDEX IF NOT EXISTS ships_owner ON ships(owner_id)`,
`CREATE INDEX IF NOT EXISTS ships_status ON ships(status)`,
`CREATE TABLE IF NOT EXISTS snapshots (