Repository navigation
feat(audit-trail): record the id a primary key moved from [PRD-1321] #1946
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,9 @@ export function defineAuditLogModel( | |
| // migration creates the column as such — this must match. Nullable: a pending create's row | ||
| // has no id yet, since the record doesn't exist until the write resolves. | ||
| recordId: { type: DataTypes.TEXT, allowNull: true }, | ||
| // Set on every confirmed update, so a null distinguishes a row older than the column from | ||
| // one whose key held still. TEXT for the same reason as `recordId`. | ||
| previousRecordId: { type: DataTypes.TEXT, allowNull: true }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium SQL persistence drops 🚀 Reply "fix it for me" or copy this AI Prompt for your agent: |
||
| userId: { type: DataTypes.INTEGER, allowNull: true }, | ||
| // Denormalised from the caller at write time — who acted then, not who holds that id today. | ||
| userFirstName: { type: DataTypes.TEXT, allowNull: true }, | ||
|
|
@@ -230,6 +233,7 @@ export function fromRow(row: Model): AuditRecord { | |
| operation: plain.operation as AuditRecord['operation'], | ||
| collection: plain.collection as string, | ||
| recordId: (plain.recordId as string) ?? null, | ||
| previousRecordId: (plain.previousRecordId as string) ?? null, | ||
| userId: plain.userId as number, | ||
| userFirstName: (plain.userFirstName as string) ?? null, | ||
| userLastName: (plain.userLastName as string) ?? null, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
audit-trail/migrations.ts:218Concurrent upgrades on SQLite/MySQL/MariaDB/MSSQL can fail agent startup: two processes can both observe
previous_record_idas absent, then the loser’s unguardedaddColumnrejects with a duplicate-column error and Umzug marks migration002as failed. Make the column addition tolerate that dialect-specific duplicate-column race (or otherwise serialize the migration) so the losing process treats it as already applied.🚀 Reply "fix it for me" or copy this AI Prompt for your agent: