using System; using Microsoft.EntityFrameworkCore.Migrations; namespace BTCPayServer.Migrations { public partial class AddOpenIddict : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "OpenIddictApplications", columns: table => new { ClientId = table.Column(maxLength: 100, nullable: false), ClientSecret = table.Column(nullable: true), ConcurrencyToken = table.Column(maxLength: 50, nullable: true), ConsentType = table.Column(nullable: true), DisplayName = table.Column(nullable: true), Id = table.Column(nullable: false), Permissions = table.Column(nullable: true), PostLogoutRedirectUris = table.Column(nullable: true), Properties = table.Column(nullable: true), RedirectUris = table.Column(nullable: true), Type = table.Column(maxLength: 25, nullable: false), ApplicationUserId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); table.ForeignKey( name: "FK_OpenIddictApplications_AspNetUsers_ApplicationUserId", column: x => x.ApplicationUserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "OpenIddictScopes", columns: table => new { ConcurrencyToken = table.Column(maxLength: 50, nullable: true), Description = table.Column(nullable: true), DisplayName = table.Column(nullable: true), Id = table.Column(nullable: false), Name = table.Column(maxLength: 200, nullable: false), Properties = table.Column(nullable: true), Resources = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); }); migrationBuilder.CreateTable( name: "OpenIddictAuthorizations", columns: table => new { ApplicationId = table.Column(nullable: true), ConcurrencyToken = table.Column(maxLength: 50, nullable: true), Id = table.Column(nullable: false), Properties = table.Column(nullable: true), Scopes = table.Column(nullable: true), Status = table.Column(maxLength: 25, nullable: false), Subject = table.Column(maxLength: 450, nullable: false), Type = table.Column(maxLength: 25, nullable: false) }, constraints: table => { table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); table.ForeignKey( name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "OpenIddictTokens", columns: table => new { ApplicationId = table.Column(nullable: true), AuthorizationId = table.Column(nullable: true), ConcurrencyToken = table.Column(maxLength: 50, nullable: true), CreationDate = table.Column(nullable: true), ExpirationDate = table.Column(nullable: true), Id = table.Column(nullable: false), Payload = table.Column(nullable: true), Properties = table.Column(nullable: true), ReferenceId = table.Column(maxLength: 100, nullable: true), Status = table.Column(maxLength: 25, nullable: false), Subject = table.Column(maxLength: 450, nullable: false), Type = table.Column(maxLength: 25, nullable: false) }, constraints: table => { table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", column: x => x.ApplicationId, principalTable: "OpenIddictApplications", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", column: x => x.AuthorizationId, principalTable: "OpenIddictAuthorizations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_OpenIddictApplications_ApplicationUserId", table: "OpenIddictApplications", column: "ApplicationUserId"); migrationBuilder.CreateIndex( name: "IX_OpenIddictApplications_ClientId", table: "OpenIddictApplications", column: "ClientId", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", table: "OpenIddictAuthorizations", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); migrationBuilder.CreateIndex( name: "IX_OpenIddictScopes_Name", table: "OpenIddictScopes", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_AuthorizationId", table: "OpenIddictTokens", column: "AuthorizationId"); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ReferenceId", table: "OpenIddictTokens", column: "ReferenceId", unique: true); migrationBuilder.CreateIndex( name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", table: "OpenIddictTokens", columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OpenIddictScopes"); migrationBuilder.DropTable( name: "OpenIddictTokens"); migrationBuilder.DropTable( name: "OpenIddictAuthorizations"); migrationBuilder.DropTable( name: "OpenIddictApplications"); } } }