Skip to content

Commit

Permalink
Fix Import SurrogateId Collision (#3768)
Browse files Browse the repository at this point in the history
* Test adding resource id check

* Updated sproc and updated schema version

* Updated SQL

* Updated csproj
  • Loading branch information
mikaelweave authored Mar 22, 2024
1 parent 6afd273 commit 8c33506
Show file tree
Hide file tree
Showing 7 changed files with 5,867 additions and 4 deletions.

Large diffs are not rendered by default.

5,443 changes: 5,443 additions & 0 deletions src/Microsoft.Health.Fhir.SqlServer/Features/Schema/Migrations/75.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ public enum SchemaVersion
V72 = 72,
V73 = 73,
V74 = 74,
V75 = 75,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Health.Fhir.SqlServer.Features.Schema
public static class SchemaVersionConstants
{
public const int Min = (int)SchemaVersion.V69;
public const int Max = (int)SchemaVersion.V74;
public const int Max = (int)SchemaVersion.V75;
public const int MinForUpgrade = (int)SchemaVersion.V69; // this is used for upgrade tests only
public const int SearchParameterStatusSchemaVersion = (int)SchemaVersion.V6;
public const int SupportForReferencesWithMissingTypeVersion = (int)SchemaVersion.V7;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ Go

INSERT INTO dbo.SchemaVersion
VALUES
(74, 'started')
(75, 'started')

Go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ BEGIN TRY
FROM (SELECT TOP (@DummyTop) * FROM @Resources) A
JOIN dbo.Resource B WITH (ROWLOCK, HOLDLOCK) ON B.ResourceTypeId = A.ResourceTypeId AND B.ResourceSurrogateId = A.ResourceSurrogateId
WHERE B.IsHistory = 0
AND B.ResourceId = A.ResourceId
AND B.Version = A.Version
OPTION (MAXDOP 1, OPTIMIZE FOR (@DummyTop = 1))

IF @@rowcount > 0 SET @IsRetry = 1
IF @@rowcount = (SELECT count(*) FROM @Resources) SET @IsRetry = 1

IF @IsRetry = 0 COMMIT TRANSACTION -- commit check transaction
END
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- Properties used by sql task to generate full script -->
<PropertyGroup>
<LatestSchemaVersion>74</LatestSchemaVersion>
<LatestSchemaVersion>75</LatestSchemaVersion>
<GeneratedFullScriptPath>Features\Schema\Migrations\$(LatestSchemaVersion).sql</GeneratedFullScriptPath>
</PropertyGroup>

Expand Down

0 comments on commit 8c33506

Please sign in to comment.