Cannot migrate Azure SQL IdentityServer database from 6.3.8 to 7.1.0 #21
-
Which version of Duende IdentityServer are you using? Which version of .NET are you using? Describe the bug Even scaling up the database from Standard/S0 to S4 did not help. It still eats up all DTUs. After checking back the IdentityServer upgrade guide I remembed that it introduced a new table ServerSideSessions and shortly thereafter changed the data type for the PK from int to bigint. I also read your note again mentioning that this might cause problems. As a next step I therefore plan to merge those two migration steps because I do not need them separately - the previous version was not yet deployed to any productive instance. I hope that will resolve the issue and will follow up with results. I will go for the weekend first however. Steps to reproduce the behavior.
Expected behavior The migration should succeed. Log output/exception with stacktrace
|
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 2 replies
-
I have not been able to merge the two versions, as another of our team was already using it. Instead I choose to work with a temporary table and drop / re-create the ServerSideSession table. migrationBuilder.Sql("SELECT [Id], [Key], [Scheme], [SubjectId], [SessionId], [DisplayName], [Created], [Renewed], [Expires], [Data] INTO TempServerSideSessions FROM ServerSideSessions");
migrationBuilder.Sql("DROP TABLE ServerSideSessions");
migrationBuilder.CreateTable(
name: "ServerSideSessions",
columns: table => new
{
// datatype changed from int to bigint
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Key = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Scheme = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
SubjectId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
SessionId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
DisplayName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
Created = table.Column<DateTime>(type: "datetime2", nullable: false),
Renewed = table.Column<DateTime>(type: "datetime2", nullable: false),
Expires = table.Column<DateTime>(type: "datetime2", nullable: true),
Data = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ServerSideSessions", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_ServerSideSessions_DisplayName",
table: "ServerSideSessions",
column: "DisplayName");
migrationBuilder.CreateIndex(
name: "IX_ServerSideSessions_Expires",
table: "ServerSideSessions",
column: "Expires");
migrationBuilder.CreateIndex(
name: "IX_ServerSideSessions_Key",
table: "ServerSideSessions",
column: "Key",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ServerSideSessions_SessionId",
table: "ServerSideSessions",
column: "SessionId");
migrationBuilder.CreateIndex(
name: "IX_ServerSideSessions_SubjectId",
table: "ServerSideSessions",
column: "SubjectId");
migrationBuilder.Sql("SET IDENTITY_INSERT ServerSideSessions ON");
migrationBuilder.Sql("INSERT INTO ServerSideSessions([Id], [Key], [Scheme], [SubjectId], [SessionId], [DisplayName], [Created], [Renewed], [Expires], [Data]) SELECT [Id], [Key], [Scheme], [SubjectId], [SessionId], [DisplayName], [Created], [Renewed], [Expires], [Data] FROM TempServerSideSessions");
migrationBuilder.Sql("SET IDENTITY_INSERT ServerSideSessions OFF");
migrationBuilder.Sql("DROP TABLE TempServerSideSessions"); |
Beta Was this translation helpful? Give feedback.
-
(note: we're moving this issue to our new community discussions) |
Beta Was this translation helpful? Give feedback.
I have not been able to merge the two versions, as another of our team was already using it. Instead I choose to work with a temporary table and drop / re-create the ServerSideSession table.
This works for us: