* Added migrations to install EF Core OpenIddict tables * Handle Install of ef core data (Needs to be outside of transaction * Cleanup and renaming, as these things will be reused for more than openiddict in the future * Cleanup * Extract db context setup * Minor cleanup --------- Co-authored-by: Nikolaj <nikolajlauridsen@protonmail.ch>
164 lines
8.3 KiB
C#
164 lines
8.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Umbraco.Cms.Persistence.EFCore.Sqlite.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "umbracoOpenIddictApplications",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
|
ClientId = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
|
|
ClientSecret = table.Column<string>(type: "TEXT", nullable: true),
|
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
ConsentType = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
DisplayName = table.Column<string>(type: "TEXT", nullable: true),
|
|
DisplayNames = table.Column<string>(type: "TEXT", nullable: true),
|
|
Permissions = table.Column<string>(type: "TEXT", nullable: true),
|
|
PostLogoutRedirectUris = table.Column<string>(type: "TEXT", nullable: true),
|
|
Properties = table.Column<string>(type: "TEXT", nullable: true),
|
|
RedirectUris = table.Column<string>(type: "TEXT", nullable: true),
|
|
Requirements = table.Column<string>(type: "TEXT", nullable: true),
|
|
Type = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_umbracoOpenIddictApplications", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "umbracoOpenIddictScopes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
Description = table.Column<string>(type: "TEXT", nullable: true),
|
|
Descriptions = table.Column<string>(type: "TEXT", nullable: true),
|
|
DisplayName = table.Column<string>(type: "TEXT", nullable: true),
|
|
DisplayNames = table.Column<string>(type: "TEXT", nullable: true),
|
|
Name = table.Column<string>(type: "TEXT", maxLength: 200, nullable: true),
|
|
Properties = table.Column<string>(type: "TEXT", nullable: true),
|
|
Resources = table.Column<string>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_umbracoOpenIddictScopes", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "umbracoOpenIddictAuthorizations",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
|
ApplicationId = table.Column<string>(type: "TEXT", nullable: true),
|
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
Properties = table.Column<string>(type: "TEXT", nullable: true),
|
|
Scopes = table.Column<string>(type: "TEXT", nullable: true),
|
|
Status = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
Subject = table.Column<string>(type: "TEXT", maxLength: 400, nullable: true),
|
|
Type = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_umbracoOpenIddictAuthorizations", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_umbracoOpenIddictAuthorizations_umbracoOpenIddictApplications_ApplicationId",
|
|
column: x => x.ApplicationId,
|
|
principalTable: "umbracoOpenIddictApplications",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "umbracoOpenIddictTokens",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
|
ApplicationId = table.Column<string>(type: "TEXT", nullable: true),
|
|
AuthorizationId = table.Column<string>(type: "TEXT", nullable: true),
|
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
CreationDate = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
ExpirationDate = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
Payload = table.Column<string>(type: "TEXT", nullable: true),
|
|
Properties = table.Column<string>(type: "TEXT", nullable: true),
|
|
RedemptionDate = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
ReferenceId = table.Column<string>(type: "TEXT", maxLength: 100, nullable: true),
|
|
Status = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
|
Subject = table.Column<string>(type: "TEXT", maxLength: 400, nullable: true),
|
|
Type = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_umbracoOpenIddictTokens", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_umbracoOpenIddictTokens_umbracoOpenIddictApplications_ApplicationId",
|
|
column: x => x.ApplicationId,
|
|
principalTable: "umbracoOpenIddictApplications",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_umbracoOpenIddictTokens_umbracoOpenIddictAuthorizations_AuthorizationId",
|
|
column: x => x.AuthorizationId,
|
|
principalTable: "umbracoOpenIddictAuthorizations",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_umbracoOpenIddictApplications_ClientId",
|
|
table: "umbracoOpenIddictApplications",
|
|
column: "ClientId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_umbracoOpenIddictAuthorizations_ApplicationId_Status_Subject_Type",
|
|
table: "umbracoOpenIddictAuthorizations",
|
|
columns: new[] { "ApplicationId", "Status", "Subject", "Type" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_umbracoOpenIddictScopes_Name",
|
|
table: "umbracoOpenIddictScopes",
|
|
column: "Name",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_umbracoOpenIddictTokens_ApplicationId_Status_Subject_Type",
|
|
table: "umbracoOpenIddictTokens",
|
|
columns: new[] { "ApplicationId", "Status", "Subject", "Type" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_umbracoOpenIddictTokens_AuthorizationId",
|
|
table: "umbracoOpenIddictTokens",
|
|
column: "AuthorizationId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_umbracoOpenIddictTokens_ReferenceId",
|
|
table: "umbracoOpenIddictTokens",
|
|
column: "ReferenceId",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "umbracoOpenIddictScopes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "umbracoOpenIddictTokens");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "umbracoOpenIddictAuthorizations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "umbracoOpenIddictApplications");
|
|
}
|
|
}
|
|
}
|