56 lines
2.1 KiB
C#
56 lines
2.1 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace StalwartSimpleLoginMiddleware.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ApiKeys",
|
|
columns: table => new
|
|
{
|
|
Key = table.Column<string>(type: "character varying(88)", unicode: false, maxLength: 88, nullable: false),
|
|
OwnerEmail = table.Column<string>(type: "character varying(254)", maxLength: 254, nullable: false),
|
|
IsAdmin = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ApiKeys", x => x.Key);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Members",
|
|
columns: table => new
|
|
{
|
|
ApiKeyId = table.Column<string>(type: "character varying(88)", maxLength: 88, nullable: false),
|
|
Email = table.Column<string>(type: "character varying(254)", maxLength: 254, nullable: false),
|
|
IsExternal = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Members", x => new { x.ApiKeyId, x.Email });
|
|
table.ForeignKey(
|
|
name: "FK_Members_ApiKeys_ApiKeyId",
|
|
column: x => x.ApiKeyId,
|
|
principalTable: "ApiKeys",
|
|
principalColumn: "Key",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Members");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ApiKeys");
|
|
}
|
|
}
|
|
}
|