using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ZeroFramework.IdentityServer.API.Migrations.PersistedGrantMigrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "DeviceCodes", columns: table => new { UserCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), DeviceCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), CreationTime = table.Column(type: "datetime2", nullable: false), Expiration = table.Column(type: "datetime2", nullable: false), Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false) }, constraints: table => { table.PrimaryKey("PK_DeviceCodes", x => x.UserCode); }); migrationBuilder.CreateTable( name: "Keys", columns: table => new { Id = table.Column(type: "nvarchar(450)", nullable: false), Version = table.Column(type: "int", nullable: false), Created = table.Column(type: "datetime2", nullable: false), Use = table.Column(type: "nvarchar(450)", nullable: true), Algorithm = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), IsX509Certificate = table.Column(type: "bit", nullable: false), DataProtected = table.Column(type: "bit", nullable: false), Data = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Keys", x => x.Id); }); migrationBuilder.CreateTable( name: "PersistedGrants", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), CreationTime = table.Column(type: "datetime2", nullable: false), Expiration = table.Column(type: "datetime2", nullable: true), ConsumedTime = table.Column(type: "datetime2", nullable: true), Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false) }, constraints: table => { table.PrimaryKey("PK_PersistedGrants", x => x.Id); }); migrationBuilder.CreateTable( name: "ServerSideSessions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Key = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), Scheme = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), SubjectId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), DisplayName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), Created = table.Column(type: "datetime2", nullable: false), Renewed = table.Column(type: "datetime2", nullable: false), Expires = table.Column(type: "datetime2", nullable: true), Data = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ServerSideSessions", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_DeviceCodes_DeviceCode", table: "DeviceCodes", column: "DeviceCode", unique: true); migrationBuilder.CreateIndex( name: "IX_DeviceCodes_Expiration", table: "DeviceCodes", column: "Expiration"); migrationBuilder.CreateIndex( name: "IX_Keys_Use", table: "Keys", column: "Use"); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_ConsumedTime", table: "PersistedGrants", column: "ConsumedTime"); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_Expiration", table: "PersistedGrants", column: "Expiration"); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_Key", table: "PersistedGrants", column: "Key", unique: true, filter: "[Key] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_SubjectId_ClientId_Type", table: "PersistedGrants", columns: new[] { "SubjectId", "ClientId", "Type" }); migrationBuilder.CreateIndex( name: "IX_PersistedGrants_SubjectId_SessionId_Type", table: "PersistedGrants", columns: new[] { "SubjectId", "SessionId", "Type" }); 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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DeviceCodes"); migrationBuilder.DropTable( name: "Keys"); migrationBuilder.DropTable( name: "PersistedGrants"); migrationBuilder.DropTable( name: "ServerSideSessions"); } } }