package store import ( "context" "pageswiki/internal/db" ) // Legacy operational state is retained even where its native worker is gated. func (s *Store) ensureNativeImportRetention(ctx context.Context) error { return db.ApplyPostgreSQLMigrations(ctx, s.DB, "store-import-retention", []db.PostgreSQLMigration{{Version: 1, Name: "preserve tags and legacy maintenance state", Statements: []string{ `CREATE TABLE tags(object_uuid TEXT,tag TEXT,created_at BIGINT DEFAULT (extract(epoch from now())::bigint))`, `CREATE INDEX tags_object_uuid ON tags(object_uuid)`, `CREATE TABLE document_backfills(store_id TEXT PRIMARY KEY,last_uuid TEXT NOT NULL DEFAULT '',processed BIGINT NOT NULL DEFAULT 0,completed INTEGER NOT NULL DEFAULT 0,updated_at_ms BIGINT NOT NULL)`, `CREATE TABLE zombie_gc_maintenance(singleton INTEGER PRIMARY KEY CHECK(singleton=1),grace_seconds BIGINT NOT NULL CHECK(grace_seconds>=86400))`, `CREATE TABLE activity_outbox_migrations(name TEXT PRIMARY KEY)`, `CREATE TABLE search_schema_state(name TEXT PRIMARY KEY)`, `CREATE TABLE application_import_receipts(id INTEGER PRIMARY KEY CHECK(id=1),source_fingerprint TEXT NOT NULL,document_root TEXT NOT NULL,key_fingerprint TEXT NOT NULL,report_json TEXT NOT NULL,completed_at_ms BIGINT NOT NULL)`, }, Assertions: []string{`SELECT object_uuid,tag,created_at FROM tags WHERE 1=0`, `SELECT store_id,last_uuid,processed,completed,updated_at_ms FROM document_backfills WHERE 1=0`, `SELECT singleton,grace_seconds FROM zombie_gc_maintenance WHERE 1=0`, `SELECT name FROM activity_outbox_migrations WHERE 1=0`, `SELECT name FROM search_schema_state WHERE 1=0`, `SELECT id,source_fingerprint,document_root,key_fingerprint,report_json,completed_at_ms FROM application_import_receipts WHERE 1=0`}}}) }