Remove dead resource_metadata table from unified resource store schema

The resource_metadata table (canonical_id-keyed custom_url/custom_name/
notes/tags) had no readers or writers anywhere in pulse or
pulse-enterprise; guest metadata is owned by the JSON-file store in
internal/config/guest_metadata.go keyed by instance:node:vmid. Stop
declaring the dead table and its index in fresh schemas. Deployed
databases are left alone deliberately — no DROP TABLE migration, since
a stale unused table is harmless. store_test.go now fails if a fresh
store's sqlite_master reintroduces resource_metadata.
This commit is contained in:
rcourtman
2026-08-02 23:55:43 +01:00
parent 739ccad864
commit 832ca35db5
3 changed files with 22 additions and 12 deletions
@@ -4334,3 +4334,22 @@ narrow. Shared resource adapters may admit explicit aliases such as `host`,
through the canonical resource model, but unified-resource consumers must not
reintroduce removed workload aliases or feature-local resource-type shims just
to satisfy one table, drawer, or badge surface.
### Resource store does not declare a resource_metadata table
The SQLite resource store schema in `internal/unifiedresources/store.go` no
longer declares the `resource_metadata` table (canonical_id-keyed
custom_url/custom_name/notes/tags rows) or its
`idx_resource_metadata_canonical` index. The table had no readers or writers
anywhere in the codebase, including `pulse-enterprise`; guest metadata is
owned by the JSON-file store in `internal/config/guest_metadata.go`, keyed by
`instance:node:vmid`. The unified-resource store must not grow a competing
user-metadata surface — reintroducing a metadata table here would fork
metadata ownership across two stores with different keying models.
Existing deployed databases are intentionally left alone: no `DROP TABLE`
migration is issued, because a stale unused table is harmless while a
destructive migration is not. The boundary is only that fresh schema creation
stops declaring dead tables.
`internal/unifiedresources/store_test.go` pins this by failing if a fresh
store's `sqlite_master` contains `resource_metadata`.
-12
View File
@@ -444,18 +444,6 @@ func (s *SQLiteResourceStore) initSchema() error {
CREATE INDEX IF NOT EXISTS idx_resource_exclusions_a ON resource_exclusions(resource_a);
CREATE INDEX IF NOT EXISTS idx_resource_exclusions_b ON resource_exclusions(resource_b);
CREATE TABLE IF NOT EXISTS resource_metadata (
id INTEGER PRIMARY KEY AUTOINCREMENT,
canonical_id TEXT NOT NULL UNIQUE,
custom_url TEXT,
custom_name TEXT,
notes TEXT,
tags TEXT,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_by TEXT
);
CREATE INDEX IF NOT EXISTS idx_resource_metadata_canonical ON resource_metadata(canonical_id);
CREATE TABLE IF NOT EXISTS resource_changes (
id TEXT PRIMARY KEY,
canonical_id TEXT NOT NULL,
+3
View File
@@ -60,6 +60,9 @@ func TestSQLiteResourceStoreDoesNotPersistRawOperationReceiptProtocolOrReplayAut
if strings.Contains(lower, "operation_receipt_version") || name == "operation_receipts" {
t.Fatalf("resource store acquired raw protocol or agent replay authority: table=%q schema=%q", name, schema)
}
if name == "resource_metadata" {
t.Fatalf("resource store declares the dead resource_metadata table; guest metadata lives in the JSON-file store (internal/config/guest_metadata.go): schema=%q", schema)
}
}
if err := rows.Err(); err != nil {
t.Fatal(err)