-
Notifications
You must be signed in to change notification settings - Fork 114
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 timestamp fields to database tables #678
Conversation
Signed-off-by: Salim Afiune <[email protected]>
var sg serviceGroup | ||
err := db.SelectOne(&sg, "SELECT * FROM service_group WHERE id = $1", id) | ||
var sgName string | ||
err := db.SelectOne(&sgName, "SELECT name FROM service_group WHERE id = $1", id) |
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.
💯
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.
Looks good 👍
Signed-off-by: Salim Afiune <[email protected]>
Signed-off-by: Salim Afiune <[email protected]>
Signed-off-by: Salim Afiune <[email protected]>
Signed-off-by: Salim Afiune <[email protected]>
Signed-off-by: Salim Afiune <[email protected]>
Can we add a test that ensures created_at timestamp doesn't get updated on update? Or just manually test that to make sure. |
@kmacgugan already tested it since I added the function, triggers, and procedures. I would love if you could also test it to give your +1 I could also add a test but I am trying to slice my PRs so that they don't get too big. |
@kmacgugan BTW Welcome back!!! |
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.
One of the tests could be strengthened. The rest LGTM 👍
assert.Nil(t, svc) | ||
} | ||
|
||
func TestStorageGetServiceFromUniqueFieldsEmptyParameters(t *testing.T) { |
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.
This test doesn't seem to be testing much since the storage is empty. Maybe you could insert the hab event from the next test and then check that the following all return false:
suite.StorageClient.GetServiceFromUniqueFields("", "")
suite.StorageClient.GetServiceFromUniqueFields("postgres", "")
suite.StorageClient.GetServiceFromUniqueFields("", "1q2w3e4r")
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.
Will do
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.
Though, now that I am doing this modification, it doesn't matter if we have something in the database or not since we have verifications that check if any of the parameters is empty, we just return immediately without running a query. Should I still modify it?
if assert.True(t, exist) { | ||
updatedOccurredAtTimestamp = svc.LastEventOccurredAt | ||
|
||
// thea substraction from the initial and the updated timestamp should be greater than a second |
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.
typo
Signed-off-by: Salim Afiune <[email protected]>
Signed-off-by: Salim Afiune <[email protected]>
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.
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.
🔩 Description
We are adding timestamps to all our tables inside the applications-service.
👍 Definition of Done
Every table in the database has
created_at
andupdated_at
timestamps.Additionally, we will start storing the timestamp of when habitat submitted
the event message. (new column in service table
last_event_occurred_at
)👟 Demo Script / Repro Steps
Build and start the applications-service and run the integration tests,
you can also login to the database and list the data.
⛓️ Related Resources
https://chefio.atlassian.net/browse/A2-892
✅ Checklist