75 lines
2.8 KiB
C#
75 lines
2.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace MyOffice.Migrations.Postgres.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class accountcategory : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "AccountCategory",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AccountCategory", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AccountAccountCategory",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
AccountId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CategoryId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AccountAccountCategory", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_AccountAccountCategory_AccountCategory_AccountId",
|
|
column: x => x.AccountId,
|
|
principalTable: "AccountCategory",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_AccountAccountCategory_Accounts_CategoryId",
|
|
column: x => x.CategoryId,
|
|
principalTable: "Accounts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AccountAccountCategory_AccountId",
|
|
table: "AccountAccountCategory",
|
|
column: "AccountId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AccountAccountCategory_CategoryId",
|
|
table: "AccountAccountCategory",
|
|
column: "CategoryId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "AccountAccountCategory");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AccountCategory");
|
|
}
|
|
}
|
|
}
|