Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(db): KAM-325: record data change logs with triggers #7239

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

passcod
Copy link
Member

@passcod passcod commented Feb 19, 2025

Changes

  • Adds a logs.changes table modelled on the data schema we nailed in the prepper work
    • Lives in the logs schema which is excluded from lean backups but included in full backups
    • Not included in public schema so it doesn't get its own triggers
  • Adds a trigger to most tables in public schema to save their changes in that table
  • Changes the trigger system to remove the triggers altogether pre-migrations
  • Adds a guard to the trigger auto-adder to only add the triggers when the function is available
  • Refactor a little to remove code duplication and use better practices (binds vs string interpolation in queries)

A separate PR will create a manual release step upgrade command which copies all the current state of the tables into logs.changes.

  • Use the last updated by column name introduced by nassau
  • Make sure we're defaulting that to the system user
  • Make sure the system user exists
  • Use synced time offset (see nassau's work) for the logged_at timestamp
  • Sync it
  • Mobile doesn't record its own logs but instead that happens on central sync
  • Have a session variable or something that can override the last updated by, so that can be used for records that come from mobile and authed context

@passcod passcod marked this pull request as ready for review February 20, 2025 04:24
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