114 lines
4.7 KiB
C#
114 lines
4.7 KiB
C#
|
|
using System;
|
|||
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|
|||
|
|
#nullable disable
|
|||
|
|
|
|||
|
|
namespace public_valetax.Migrations
|
|||
|
|
{
|
|||
|
|
/// <inheritdoc />
|
|||
|
|
public partial class InitialCreate : Migration
|
|||
|
|
{
|
|||
|
|
/// <inheritdoc />
|
|||
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
|
{
|
|||
|
|
migrationBuilder.CreateTable(
|
|||
|
|
name: "journal_entries",
|
|||
|
|
columns: table => new
|
|||
|
|
{
|
|||
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|||
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
|
event_id = table.Column<long>(type: "bigint", nullable: false),
|
|||
|
|
timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|||
|
|
query_parameters = table.Column<string>(type: "text", nullable: true),
|
|||
|
|
body_parameters = table.Column<string>(type: "text", nullable: true),
|
|||
|
|
stack_trace = table.Column<string>(type: "text", nullable: true),
|
|||
|
|
exception_type = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|||
|
|
message = table.Column<string>(type: "text", nullable: false)
|
|||
|
|
},
|
|||
|
|
constraints: table =>
|
|||
|
|
{
|
|||
|
|
table.PrimaryKey("PK_journal_entries", x => x.id);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateTable(
|
|||
|
|
name: "trees",
|
|||
|
|
columns: table => new
|
|||
|
|
{
|
|||
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|||
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
|
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|||
|
|
created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|||
|
|
},
|
|||
|
|
constraints: table =>
|
|||
|
|
{
|
|||
|
|
table.PrimaryKey("PK_trees", x => x.id);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateTable(
|
|||
|
|
name: "nodes",
|
|||
|
|
columns: table => new
|
|||
|
|
{
|
|||
|
|
id = table.Column<long>(type: "bigint", nullable: false)
|
|||
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
|
tree_id = table.Column<long>(type: "bigint", nullable: false),
|
|||
|
|
parent_id = table.Column<long>(type: "bigint", nullable: true),
|
|||
|
|
name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|||
|
|
created_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|||
|
|
},
|
|||
|
|
constraints: table =>
|
|||
|
|
{
|
|||
|
|
table.PrimaryKey("PK_nodes", x => x.id);
|
|||
|
|
table.ForeignKey(
|
|||
|
|
name: "FK_nodes_nodes_parent_id",
|
|||
|
|
column: x => x.parent_id,
|
|||
|
|
principalTable: "nodes",
|
|||
|
|
principalColumn: "id",
|
|||
|
|
onDelete: ReferentialAction.Cascade);
|
|||
|
|
table.ForeignKey(
|
|||
|
|
name: "FK_nodes_trees_tree_id",
|
|||
|
|
column: x => x.tree_id,
|
|||
|
|
principalTable: "trees",
|
|||
|
|
principalColumn: "id",
|
|||
|
|
onDelete: ReferentialAction.Cascade);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_journal_entries_event_id",
|
|||
|
|
table: "journal_entries",
|
|||
|
|
column: "event_id",
|
|||
|
|
unique: true);
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_nodes_parent_id",
|
|||
|
|
table: "nodes",
|
|||
|
|
column: "parent_id");
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_nodes_tree_id_name",
|
|||
|
|
table: "nodes",
|
|||
|
|
columns: new[] { "tree_id", "name" },
|
|||
|
|
unique: true);
|
|||
|
|
|
|||
|
|
migrationBuilder.CreateIndex(
|
|||
|
|
name: "IX_trees_name",
|
|||
|
|
table: "trees",
|
|||
|
|
column: "name",
|
|||
|
|
unique: true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <inheritdoc />
|
|||
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
|
{
|
|||
|
|
migrationBuilder.DropTable(
|
|||
|
|
name: "journal_entries");
|
|||
|
|
|
|||
|
|
migrationBuilder.DropTable(
|
|||
|
|
name: "nodes");
|
|||
|
|
|
|||
|
|
migrationBuilder.DropTable(
|
|||
|
|
name: "trees");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|