-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add automatic row timestamps for Accounts and Groups tables #1674
Conversation
Pull Request Test Coverage Report for Build 9577490268Details
💛 - Coveralls |
d75e2af
to
fc56d7c
Compare
Pull Request Test Coverage Report for Build 9577639417Details
💛 - Coveralls |
fc56d7c
to
a22412f
Compare
Pull Request Test Coverage Report for Build 9582299562Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9583178940Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9583280310Details
💛 - Coveralls |
|
||
await sql.end(); | ||
it('should add and update row timestamps', async () => { |
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.
Nit: let's add another test that then ensures the created_at
doesn't change but updated_at
does after as the after
callback combines all queries in one transaction.
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.
I've added a test in b1a9b0f
src/config/entities/configuration.ts
Outdated
@@ -175,7 +175,7 @@ export default () => ({ | |||
delegatesV2: process.env.FF_DELEGATES_V2?.toLowerCase() === 'true', | |||
counterfactualBalances: | |||
process.env.FF_COUNTERFACTUAL_BALANCES?.toLowerCase() === 'true', | |||
accounts: process.env.FF_ACCOUNTS?.toLowerCase() === 'true', | |||
accounts: true, |
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.
Was this an accidental commit?
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.
Yes 😓 I've fixed it in b1a9b0f
|
||
export type Row = z.infer<typeof RowSchema>; | ||
|
||
export const RowSchema = z.object({ |
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.
Nit: as we will be extending this for all tables, I would add some comments here as I've seen issues when using merge
, e.g. outling that id
is the primary key and caution should be taken when updating.
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.
I've added a comment in b1a9b0f
Please let me know if you want to rephrase it or add something else!
@@ -51,7 +56,8 @@ export class PostgresDatabaseMigrator { | |||
} | |||
|
|||
/** | |||
* @private migrates up to/allows for querying before/after migration to test it. | |||
* Migrates up to/allows for querying before/after migration to test it. | |||
* Uses generics to allow the caller to specify the return type of the before/after functions. |
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.
Love this!
Co-authored-by: Aaron Cook <aaron@safe.global>
Co-authored-by: Aaron Cook <aaron@safe.global>
Co-authored-by: Aaron Cook <aaron@safe.global>
Pull Request Test Coverage Report for Build 9584039461Details
💛 - Coveralls |
Summary
This PR adds
createdAt
andupdatedAt
timestamps toAccounts
andGroups
tables.createdAt
is set to the current timestamp when a new row is created and it's not meant to be modified.updatedAt
is set to the current timestamp when a new row is created and the idea is to modify it automatically using a trigger.The goal is to enhance these database tables' maintainability and auditing while improving debugging.
Changes
Row
as an entity meant to be extended by any persistence entity (id
,created_at
,updated_at
are enforced).createdAt
andupdatedAt
timestamps toAccounts
andGroups
tables.updatedAt
on each row modification.PostgresDatabaseMigrator.test
to make it generic, as the caller may need to specify the types returned to access their properties in the tests.