Skip to content

Commit

Permalink
Merge pull request #88 from SSchulze1989/develop
Browse files Browse the repository at this point in the history
v 0.10.0
  • Loading branch information
SSchulze1989 authored Oct 29, 2023
2 parents e21dedd + 4489687 commit 0d61c58
Show file tree
Hide file tree
Showing 18 changed files with 8,246 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/DatabaseBenchmarks/DatabaseBenchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="iRLeagueApiCore.Common" Version="0.9.3" />
<PackageReference Include="iRLeagueApiCore.Common" Version="0.10.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.7" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
Expand Down
3 changes: 2 additions & 1 deletion src/DatabaseBenchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Attributes;
using iRLeagueApiCore.Common.Enums;
using iRLeagueApiCore.Common.Models;
using iRLeagueDatabaseCore.Models;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -213,7 +214,7 @@ public async Task<EventResultModel> SingleEventQuery()
PositionChange = row.PositionChange,
QualifyingTime = row.QualifyingTime,
SeasonStartIrating = row.SeasonStartIRating,
Status = row.Status,
Status = (RaceStatus)row.Status,
TeamId = row.TeamId
}),
CreatedOn = sessionResult.CreatedOn,
Expand Down
2 changes: 2 additions & 0 deletions src/iRLeagueDatabaseCore/LeagueDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ private void ConfigureMultiTenancy(ModelBuilder builder)
.HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId);
builder.Entity<IncidentReviewEntity>()
.HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId);
builder.Entity<IncidentReviewsInvolvedTeams>()
.HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId);
builder.Entity<LeagueMemberEntity>()
.HasQueryFilter(mt => mt.LeagueId == LeagueProvider.LeagueId);
builder.Entity<PointRuleEntity>()
Expand Down
42 changes: 42 additions & 0 deletions src/iRLeagueDatabaseCore/MigrationCarNumberAsString.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
USE LeagueDatabase;

START TRANSACTION;

-- pre migration
-- safe the CarNumber values as ints

CREATE TEMPORARY TABLE TmpResultRowsNumbers (
ResultRowId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
CarNumber INT NOT NULL
);

INSERT INTO TmpResultRowsNumbers (ResultRowId, CarNumber)
SELECT ResultRowId, CarNumber
FROM ResultRows;

CREATE TEMPORARY TABLE TmpScoredResultRowsNumbers (
ScoredResultRowId BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
CarNumber INT NOT NULL
);

INSERT INTO TmpScoredResultRowsNumbers (ScoredResultRowId, CarNumber)
SELECT ScoredResultRowId, CarNumber
FROM ScoredResultRows;

-- post migration
-- restore CarNumber values as string

UPDATE ResultRows `rows`
JOIN TmpResultRowsNumbers `numbers`
ON `numbers`.ResultRowId=`rows`.ResultRowId
SET `rows`.CarNumber = `numbers`.CarNumber;

UPDATE ScoredResultRows `rows`
JOIN TmpScoredResultRowsNumbers `numbers`
ON `numbers`.ScoredResultRowId=`rows`.ScoredResultRowId
SET `rows`.CarNumber = `numbers`.CarNumber;

DROP TABLE TmpResultRowsNumbers;
DROP TABLE TmpScoredResultRowsNumbers;

ROLLBACK;
Loading

0 comments on commit 0d61c58

Please sign in to comment.