1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2024-11-24 22:42:53 +01:00
Minecraft-Phantom-Panel/Controller/Phantom.Controller.Database.Postgres/Migrations/20221016035515_AuditLog.cs

60 lines
2.2 KiB
C#

using System;
using System.Text.Json;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Phantom.Controller.Database.Postgres.Migrations
{
/// <inheritdoc />
public partial class AuditLog : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "system");
migrationBuilder.CreateTable(
name: "AuditEvents",
schema: "system",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<string>(type: "text", nullable: true),
UtcTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
EventType = table.Column<string>(type: "text", nullable: false),
SubjectType = table.Column<string>(type: "text", nullable: false),
SubjectId = table.Column<string>(type: "text", nullable: false),
Data = table.Column<JsonDocument>(type: "jsonb", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AuditEvents", x => x.Id);
table.ForeignKey(
name: "FK_AuditEvents_Users_UserId",
column: x => x.UserId,
principalSchema: "identity",
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_AuditEvents_UserId",
schema: "system",
table: "AuditEvents",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AuditEvents",
schema: "system");
}
}
}