Skip to content

fix(database): move audit_logs DDL into the numbered migration chain - #418

Open
nello27 wants to merge 1 commit into
XStreamRollz:mainfrom
nello27:fix/audit-logs-migration
Open

fix(database): move audit_logs DDL into the numbered migration chain#418
nello27 wants to merge 1 commit into
XStreamRollz:mainfrom
nello27:fix/audit-logs-migration

Conversation

@nello27

@nello27 nello27 commented Jul 17, 2026

Copy link
Copy Markdown

Summary

  • database/audit_logs.sql lived as a standalone file, outside database/migrations, and was missing from database/schema.sql — breaking the invariant that applying all migrations in order must reproduce schema.sql exactly.
  • Adds 2026071701_add_audit_logs.up.sql / .down.sql following the repo's migration conventions (BEGIN/COMMIT, IF NOT EXISTS guards).
  • Adds the audit_logs table to database/schema.sql.
  • Updates database/migrations/README.md listing table.
  • Removes the standalone database/audit_logs.sql.

Closes #333

Test plan

  • Applied the up migration on a fresh Postgres (Docker) DB seeded with the prior schema — table, indexes, and FK to users(id) created correctly.
  • Re-ran the up migration — confirmed idempotent (IF NOT EXISTS skips).
  • Ran the down migration — confirmed clean rollback (table dropped).
  • Re-applied up, then compared pg_dump --schema-only of the migrated DB against a DB loaded directly from schema.sql — identical (only the pg_dump \restrict tokens differ, which are random per-run).

Copy link
Copy Markdown
Contributor

Good catch and solid fix, @nello27 — keeping the audit_logs DDL inside the numbered migration chain ensures the schema evolves predictably and deployments stay repeatable. CI is green. Merging! 🚀

Copy link
Copy Markdown
Contributor

Hey @nello27, the migration chain fix is exactly the right approach and CI is green ✅.

The branch has picked up conflicts with main (mainly package-lock.json) from other PRs that landed recently. Quick rebase to clear it:

git fetch origin
git rebase origin/main
# resolve any conflicts, then
git push --force-with-lease

Ready to merge once the branch is updated!

@nello27
nello27 force-pushed the fix/audit-logs-migration branch from bbbd101 to 72feb5f Compare July 19, 2026 23:38
@Xhristin3

Copy link
Copy Markdown
Contributor

@nello27 resolve conflicts.

audit_logs.sql lived as a standalone file outside database/migrations
and was missing from schema.sql, breaking the invariant that migrations
must reproduce schema.sql exactly. Adds 2026071702_add_audit_logs
(up/down), documents it in the migrations README, and folds the table
into schema.sql.

Closes XStreamRollz#333

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@nello27
nello27 force-pushed the fix/audit-logs-migration branch from 72feb5f to 4696f47 Compare July 21, 2026 13:07
@nello27

nello27 commented Jul 21, 2026

Copy link
Copy Markdown
Author

Investigated the failing CI / quality check — it's caused by a pre-existing issue on main, unrelated to this PR:

src/streams/streams.service.spec.ts:210:15 - error TS2554: Expected 2 arguments, but got 1.
service = new StreamsService(mockRepo);
An argument for 'webhooksService' was not provided.

StreamsService's constructor now requires a webhooksService argument (likely introduced alongside the recent webhooks module), but streams.service.spec.ts:210 wasn't updated to pass it. This PR only touches database/audit_logs.sql, database/migrations/, and database/schema.sql — no changes to streams.service.ts or its tests.

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.

api: audit_logs table is a standalone SQL file not integrated into the migration system

2 participants