Skip to content

Commit

Permalink
Add composite index for data migration
Browse files Browse the repository at this point in the history
  • Loading branch information
marquestye committed Apr 18, 2024
1 parent ce839ab commit 8c5cae2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package teammates.client.scripts.sql;

import com.googlecode.objectify.cmd.Query;

import teammates.client.scripts.DataMigrationEntitiesBaseScript;
import teammates.storage.entity.Course;

/**
* Index the newly-indexable fields of courses.
*/
public class IndexCourseFields extends DataMigrationEntitiesBaseScript<Course> {

public static void main(String[] args) {
new IndexCourseFields().doOperationRemotely();
}

@Override
protected Query<Course> getFilterQuery() {
return ofy().load().type(Course.class);
}

@Override
protected boolean isPreview() {
return true;
}

@Override
protected boolean isMigrationNeeded(Course course) {
return true;
}

@Override
protected void migrateEntity(Course course) {
// Save without any update; this will build the previously non-existing indexes
saveEntityDeferred(course);
}
}
12 changes: 12 additions & 0 deletions src/main/appengine/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,15 @@ indexes:
name: targetUser
- direction: asc
name: endTime
- kind: Course
properties:
- direction: asc
name: isMigrated
- direction: asc
name: createdAt
- kind: Course
properties:
- direction: asc
name: isMigrated
- direction: desc
name: createdAt

0 comments on commit 8c5cae2

Please sign in to comment.