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

[#12048] Add migration script for Usage Statistics #12798

Merged
merged 3 commits into from
Feb 24, 2024

Conversation

kevin9foong
Copy link
Member

@kevin9foong kevin9foong commented Feb 24, 2024

Write script to migrate all usage statistics from datastore to cloudSQL

Verification:

  1. Seed DB with UsageStatistics.
    ./gradlew -PuserScript=sql/SeedUsageStatistics execScript

  2. Run the migration script in preview (im using non preview to check on live CloudSQL in the screenshot)
    ./gradlew -PuserScript=sql/DataMigrationForUsageStatisticsSql execScript
    image
    We can see the 2 seeded UsageStatistics are reported to be migrated.

  3. Verify on CloudSQL
    image
    the fields seem to match seeded datastore records.

@kevin9foong kevin9foong added the s.Ongoing The PR is being worked on by the author(s) label Feb 24, 2024
@kevin9foong kevin9foong added this to the V9.0.0 milestone Feb 24, 2024
@kevin9foong kevin9foong self-assigned this Feb 24, 2024
@kevin9foong kevin9foong changed the title Add migration script for Usage Statistics [#12048] Add migration script for Usage Statistics Feb 24, 2024
@kevin9foong kevin9foong added s.ToReview The PR is waiting for review(s) and removed s.Ongoing The PR is being worked on by the author(s) labels Feb 24, 2024
@kevin9foong kevin9foong marked this pull request as ready for review February 24, 2024 13:29
Copy link
Contributor

@NicolasCwy NicolasCwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +35 to +38
@Override
protected boolean isMigrationNeeded(teammates.storage.entity.UsageStatistics entity) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add a check: only returns true if the entity has not migrated yet? The other script does not have that check yet (only return true) as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, the check will search the cloudSQL DB and check if another record with the same Id alr exists

Copy link
Member Author

@kevin9foong kevin9foong Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ziqing26, shall we figure out how to do this check as a team tomorrow? since it likely involves including some kind of HibernateUtil to check if the SQL side already has an entity with the same ID.

We could implement the Hibernate querying logic across the board in the main base script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep using HibernateUtil to check should be the idea.

@ziqing26 ziqing26 merged commit 4803f84 into v9-non-course-data-migration Feb 24, 2024
1 check passed
@kevin9foong kevin9foong deleted the kevin/migrate-usage-statistics branch February 26, 2024 14:34
@cedricongjh cedricongjh modified the milestones: V9.0.0, V9.0.0-beta.0 Mar 10, 2024
ziqing26 added a commit that referenced this pull request Mar 10, 2024
* Add seed script

* [#12048] Add DataMigrationEntitiesBaseScriptSql and DataMigrationForAccountSql (#12766)

* Add hibernate connection

* Add DataMigrationEntitiesBaseScriptSql and example Account Migration

* [#12048] Add verify to seed db (#12767)

* Add verify

* Revert secrets

* Clean up seed script (#12768)

* Fix account migration script

* Add client property

* Add SQL notification migration script

* Modify seed script to persist to local database store

* Data migration for account

* Add seed data for data migration

* Add Account and Read Notification

* Remove comments

* [#12048] Add migration script for Usage Statistics (#12798)

* Add migration script for UsageStatistics

* Add seed script for usage statistics and add ofy support

* Set preview to true by default

* [#12048] Add migration script for Account Request (#12799)

* Add migration script for acc req

* Update migration script

* Add checks to notification script (#12836)

* Add checks to notification script

* Fix comments

* Create script to verify row count for non-course entities (#12824)

* Create script to verify row count

* Add read notification verification

* Add comment

* Add base script for verifying migrated attributes (#12841)

* Add datastore entity comparison function (except readNotification)

* Add verify attribute entity base script

Co-authored-by: Kevin Foong <[email protected]>

* Add verify usage statistics

* Add verification script for account request

* Amend base script to fetch lazily loaded keys

* Fix migration verification for notification

* Add migration verification script for account

* Save progress

* Add changes

* Fix bug

* Add changes

* Add support for pagination

* Add changes (#12846)

* Add a script to remove datastore non course entities and fix progress bar in seeddb

* Add warning for the script

* Add user check for removal script

* Revert remove script

* fix seed script to populate notification UUID correctly

* Remove unnecessary whitespace

* Add connection verification script

* Remove only one entity in Verify Connection Script

* Fix seeding of data for data migration (#12873)

* Fix notification and readNotification from having different endtime

* Fix seed data to create notification to nearest millisecond

* Remove commented out println

* Uncomment databundle persistance

* Remove unnecessary comments and fix format

* Revert logs in EntitesDb

* V9 Migration: Fix verification pagination, improve logging (#12874)

* Fix numPages division bug, add logging, testing paging

* Add logging

* Remove unnecessary function

* Remove unnecessary files, shift some functions

* Clean up branch

* Fix lint errors

* Fix lint errors v2

* Fix lint errors v3

* Fix spotBugsTest

---------

Co-authored-by: Nicolas Chang <[email protected]>
Co-authored-by: FergusMok <[email protected]>
Co-authored-by: Kevin Foong <[email protected]>
Co-authored-by: Kevin Foong <[email protected]>
Co-authored-by: Kevin Foong <[email protected]>
@wkurniawan07 wkurniawan07 modified the milestones: V9.0.0, V9.0.0-beta.1 Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s.ToReview The PR is waiting for review(s)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants