Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Feb 24, 2024
1 parent 90fed7d commit 0aa2ceb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/BUTR.CrashReportServer/Services/DatabaseMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ protected override async Task ExecuteAsync(CancellationToken ct)
const int take = 10000;

var idDataCount = sqlite.Set<IdEntity>().AsNoTracking().Count();
for (var i = 0; i < idDataCount % take; i+= take)
var idDataIterations = idDataCount % take;
for (var i = 0; i < idDataIterations; i++)
{
var data = await sqlite.Set<IdEntity>().AsNoTracking().OrderBy(x => x.FileId).Skip(i * take).Take(take).AsAsyncEnumerable()
.Select(x => x with
Expand All @@ -48,15 +49,17 @@ protected override async Task ExecuteAsync(CancellationToken ct)
}

var fileDataCount = sqlite.Set<FileEntity>().AsNoTracking().Count();
for (var i = 0; i < fileDataCount % take; i+= take)
var fileDataIterations = fileDataCount % take;
for (var i = 0; i < fileDataIterations; i+= take)
{
var data = await sqlite.Set<FileEntity>().AsNoTracking().OrderBy(x => x.Id.FileId).Skip(i * take).Take(take).ToArrayAsync(ct);
await postgres.Set<FileEntity>().AddRangeAsync(data, ct);
await postgres.SaveChangesAsync(ct);
}

var jsonDataCount = sqlite.Set<OldJsonEntity>().AsNoTracking().Count();
for (var i = 0; i < jsonDataCount % take; i+= take)
var jsonDataIterations = jsonDataCount % take;
for (var i = 0; i < jsonDataIterations; i+= take)
{
var data = await sqlite.Set<OldJsonEntity>().OrderBy(x => x.Id.FileId).Skip(i * take).Take(take).AsAsyncEnumerable()
.SelectAwait(async x => new JsonEntity
Expand Down

0 comments on commit 0aa2ceb

Please sign in to comment.