Skip to content

Commit 0c5c344

Browse files
committed
delete after copying records
1 parent 24ba4bd commit 0c5c344

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

server/api-service/lowcoder-server/src/main/java/org/lowcoder/runner/migrations/DatabaseChangelog.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.github.cloudyrock.mongock.ChangeSet;
55
import com.github.cloudyrock.mongock.driver.mongodb.springdata.v4.decorator.impl.MongockTemplate;
66
import com.github.f4b6a3.uuid.UuidCreator;
7+
import com.mongodb.client.result.DeleteResult;
78
import lombok.extern.slf4j.Slf4j;
89
import org.bson.Document;
910
import org.lowcoder.domain.application.model.Application;
@@ -351,6 +352,10 @@ public void addTimeSeriesSnapshotHistory(MongockTemplate mongoTemplate, CommonCo
351352
.aggregate(Arrays.asList(match, project, out))
352353
.toCollection();
353354

355+
// Delete the migrated records
356+
Query deleteQuery = new Query(Criteria.where("createdAt").gte(thresholdDate));
357+
DeleteResult deleteResult = mongoTemplate.remove(deleteQuery, ApplicationHistorySnapshot.class);
358+
354359
ensureIndexes(mongoTemplate, ApplicationHistorySnapshotTS.class,
355360
makeIndex("applicationId"),
356361
makeIndex("createdAt"));

0 commit comments

Comments
 (0)