using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace public_valetax.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "journal_entries", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), event_id = table.Column(type: "bigint", nullable: false), timestamp = table.Column(type: "timestamp with time zone", nullable: false), query_parameters = table.Column(type: "text", nullable: true), body_parameters = table.Column(type: "text", nullable: true), stack_trace = table.Column(type: "text", nullable: true), exception_type = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), message = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_journal_entries", x => x.id); }); migrationBuilder.CreateTable( name: "trees", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), created_at = table.Column(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(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), tree_id = table.Column(type: "bigint", nullable: false), parent_id = table.Column(type: "bigint", nullable: true), name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), created_at = table.Column(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); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "journal_entries"); migrationBuilder.DropTable( name: "nodes"); migrationBuilder.DropTable( name: "trees"); } } }