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 composite index for data migration #13057

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
NicolasCwy marked this conversation as resolved.
Show resolved Hide resolved
- direction: asc
name: createdAt
- kind: Course
properties:
- direction: asc
name: isMigrated
- direction: desc
name: createdAt
Loading