-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[#12048] Add patch script for account request and notifications to amend createdAt field #13077
[#12048] Add patch script for account request and notifications to amend createdAt field #13077
Conversation
// Get first items since there is guaranteed to be one | ||
teammates.storage.sqlentity.AccountRequest newAccountReq = matchingAccounts.get(0); | ||
newAccountReq.setCreatedAt(oldEntity.getCreatedAt()); | ||
HibernateUtil.commitTransaction(); |
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.
Since we're fetching an existing entity, changing the object attribute will save the changes in the DB
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.
LGTM!
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.
Only the indexing 0 should be problem, LGTM
if (matchingAccounts.size() > 1) { | ||
throw new Error("More than one matching account request found"); | ||
} else if (matchingAccounts.size() == 0){ | ||
throw new Error("No matching account found"); | ||
} | ||
|
||
// Get first items since there is guaranteed to be one | ||
teammates.storage.sqlentity.AccountRequest newAccountReq = matchingAccounts.get(0); |
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.
What if the account request has already been processed / deleted in SQL? I didn't look into how accounts are created, but does it delete the request?
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.
* Returns the filter query. | ||
*/ | ||
protected Query<teammates.storage.entity.AccountRequest> getFilterQuery() { | ||
return ofy().load().type(teammates.storage.entity.AccountRequest.class); |
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.
Not important, only if you have time.
https://cloud.google.com/datastore/docs/concepts/queries#projection_queries
Not sure if we can do a projection query to speed up, since we're only interested in institute, email, name and createdAt. Objectify has a project()
Part of #12048
Context
Previously during the non-course migration,
createdAt
was not migrated due to having the@createdTimestamp
annotation. This was removed in the v9-course-migration branch and can be used for this as well.Outline of Solution
Add 2 scripts based of
PatchDataMigrationForUsageStatisticsSql
to fetch existing account requests and notifications using fields which are identifiers for the entity and amend theircreatedAt
timestamp. Most of the changes are inMigrateEntity
method. Verification Scripts can handle the case where an entity exist in postgres but not in datastore (since we have started created new account requests and notification in postgres)Fields which are identifiers