Skip to content

Instantly share code, notes, and snippets.

@georgepaoli
Created January 20, 2021 11:41
Show Gist options
  • Save georgepaoli/bdacf03babe099ff7fe6cd2b68b36ba9 to your computer and use it in GitHub Desktop.
Save georgepaoli/bdacf03babe099ff7fe6cd2b68b36ba9 to your computer and use it in GitHub Desktop.
IdentityServer4 SQL scripts for SqlServer: PersistedGrants and DeviceCodes tables
CREATE TABLE "PersistedGrants"
(
"Key" varchar(200) NOT NULL,
"Type" varchar(50) NOT NULL,
"SubjectId" varchar(200),
"SessionId" varchar(100),
"ClientId" varchar(200) NOT NULL,
"Description" varchar(200),
"CreationTime" datetime NOT NULL,
"Expiration" datetime,
"ConsumedTime" datetime,
"Data" varchar(max) NOT NULL,
CONSTRAINT "PK_PersistedGrants" PRIMARY KEY ("Key")
)
GO
CREATE INDEX "IX_PersistedGrants_Expiration" ON "PersistedGrants" ("Expiration");
CREATE INDEX "IX_PersistedGrants_SubjectId_ClientId_Type" ON "PersistedGrants" ("SubjectId", "ClientId", "Type");
CREATE INDEX "IX_PersistedGrants_SubjectId_SessionId_Type" ON "PersistedGrants" ("SubjectId", "SessionId", "Type");
GO
CREATE TABLE "DeviceCodes"
(
"UserCode" varchar(200) NOT NULL,
"DeviceCode" varchar(200) NOT NULL,
"SubjectId" varchar(200),
"SessionId" varchar(100),
"ClientId" varchar(200) NOT NULL,
"Description" varchar(200),
"CreationTime" datetime NOT NULL,
"Expiration" datetime NOT NULL,
"Data" varchar(max) NOT NULL,
CONSTRAINT "PK_DeviceCodes" PRIMARY KEY ("UserCode")
)
GO
CREATE UNIQUE INDEX "IX_DeviceCodes_DeviceCode" ON "DeviceCodes" ("DeviceCode");
CREATE INDEX "IX_DeviceCodes_Expiration" ON "DeviceCodes" ("Expiration");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment