chore(db): stop the data baseline from creating the unused auth/audit tables - #400
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api_keysandaudit_logsbelong to the separate main SQLite connection (auth + audit). But the data-connection baseline migration (1770108659848-AddMessageStatus) also created them — with a stalekeyPrefix varchar(8)(the entity and the main migration usevarchar(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_logsCREATE/index statements from the baseline (both SQLite and Postgresup()), the matchingDROPs fromdown()(kept symmetric), and drops the two from theAddUuidDefaultsForPostgrestable 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
DROPmigration 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): afterup()on a fresh DB,api_keys/audit_logsare 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.Risk
Low, and scoped to fresh installs. No data is dropped or migrated on existing deployments;
up/downstay symmetric so a fresh-DB rollback still succeeds.