Skip to content

chore(db): stop the data baseline from creating the unused auth/audit tables - #400

Merged
rmyndharis merged 2 commits into
mainfrom
chore/data-baseline-schema-hygiene
Jun 21, 2026
Merged

chore(db): stop the data baseline from creating the unused auth/audit tables#400
rmyndharis merged 2 commits into
mainfrom
chore/data-baseline-schema-hygiene

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

Summary

api_keys and audit_logs belong to the separate main SQLite connection (auth + audit). But the data-connection baseline migration (1770108659848-AddMessageStatus) also created them — with a stale keyPrefix varchar(8) (the entity and the main migration use varchar(12)) — leaving two dead, never-read tables on the data database, and a latent Postgres truncation hazard if auth were ever re-pointed at the data connection.

This removes the api_keys/audit_logs CREATE/index statements from the baseline (both SQLite and Postgres up()), the matching DROPs from down() (kept symmetric), and drops the two from the AddUuidDefaultsForPostgres table list. Fresh data DBs no longer carry them.

Existing installs are not touched

TypeORM never re-runs an applied migration, so an existing install keeps its (harmless) leftover tables — this change only affects what a fresh database builds. No DROP migration is added on purpose: an unconditional drop could destroy a shared-file install's live auth tables, and the path-collision guard added in #399 already prevents that misconfiguration going forward.

Tests

  • __tests__/1770108659848-AddMessageStatus.spec.ts (real in-memory SQLite): after up() on a fresh DB, api_keys/audit_logs are now asserted absent (sessions/webhooks/messages/message_batches still present); the synchronize-adoption no-op test is unchanged.
  • add-uuid-defaults-migration.spec.ts: table list updated to the four data-owned tables.
  • Full gate: lint 0 · build OK · 1052 unit · 26 e2e · dashboard build + lint clean.

Risk

Low, and scoped to fresh installs. No data is dropped or migrated on existing deployments; up/down stay symmetric so a fresh-DB rollback still succeeds.

… tables

api_keys/audit_logs belong to the separate 'main' SQLite connection, but the
data-connection baseline migration also created them (with a stale keyPrefix
varchar(8) vs the entity's varchar(12)) — dead, unused tables on the data DB.
Remove their CREATE/index statements from the baseline (SQLite + Postgres up()),
the matching DROPs from down(), and drop them from the AddUuidDefaults table list,
so fresh data DBs no longer carry them.

Existing installs are unaffected: TypeORM never re-runs an applied migration, so
their harmless leftover tables remain. No DROP migration is added — a DROP could
destroy a shared-file install's live auth tables; the new path-collision guard
already prevents that misconfiguration going forward.
@rmyndharis
rmyndharis merged commit d2d8755 into main Jun 21, 2026
5 checks passed
@rmyndharis
rmyndharis deleted the chore/data-baseline-schema-hygiene branch June 21, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant