Files
myoffice/MyOffice.Migration.Postgres/Migrations/20230601121013_AccountCategories.cs
T
2023-06-17 14:16:09 +03:00

172 lines
6.3 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MyOffice.Migrations.Postgres.Migrations
{
/// <inheritdoc />
public partial class AccountCategories : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AccountAccountCategory_AccountCategory_AccountId",
table: "AccountAccountCategory");
migrationBuilder.DropForeignKey(
name: "FK_AccountAccountCategory_Accounts_CategoryId",
table: "AccountAccountCategory");
migrationBuilder.DropPrimaryKey(
name: "PK_AccountCategory",
table: "AccountCategory");
migrationBuilder.DropPrimaryKey(
name: "PK_AccountAccountCategory",
table: "AccountAccountCategory");
migrationBuilder.RenameTable(
name: "AccountCategory",
newName: "AccountCategories");
migrationBuilder.RenameTable(
name: "AccountAccountCategory",
newName: "AccountAccountCategories");
migrationBuilder.RenameIndex(
name: "IX_AccountAccountCategory_CategoryId",
table: "AccountAccountCategories",
newName: "IX_AccountAccountCategories_CategoryId");
migrationBuilder.RenameIndex(
name: "IX_AccountAccountCategory_AccountId",
table: "AccountAccountCategories",
newName: "IX_AccountAccountCategories_AccountId");
migrationBuilder.AddColumn<Guid>(
name: "UserId",
table: "AccountCategories",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddPrimaryKey(
name: "PK_AccountCategories",
table: "AccountCategories",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_AccountAccountCategories",
table: "AccountAccountCategories",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_AccountCategories_UserId",
table: "AccountCategories",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_AccountAccountCategories_AccountCategories_AccountId",
table: "AccountAccountCategories",
column: "AccountId",
principalTable: "AccountCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AccountAccountCategories_Accounts_CategoryId",
table: "AccountAccountCategories",
column: "CategoryId",
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AccountCategories_Users_UserId",
table: "AccountCategories",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AccountAccountCategories_AccountCategories_AccountId",
table: "AccountAccountCategories");
migrationBuilder.DropForeignKey(
name: "FK_AccountAccountCategories_Accounts_CategoryId",
table: "AccountAccountCategories");
migrationBuilder.DropForeignKey(
name: "FK_AccountCategories_Users_UserId",
table: "AccountCategories");
migrationBuilder.DropPrimaryKey(
name: "PK_AccountCategories",
table: "AccountCategories");
migrationBuilder.DropIndex(
name: "IX_AccountCategories_UserId",
table: "AccountCategories");
migrationBuilder.DropPrimaryKey(
name: "PK_AccountAccountCategories",
table: "AccountAccountCategories");
migrationBuilder.DropColumn(
name: "UserId",
table: "AccountCategories");
migrationBuilder.RenameTable(
name: "AccountCategories",
newName: "AccountCategory");
migrationBuilder.RenameTable(
name: "AccountAccountCategories",
newName: "AccountAccountCategory");
migrationBuilder.RenameIndex(
name: "IX_AccountAccountCategories_CategoryId",
table: "AccountAccountCategory",
newName: "IX_AccountAccountCategory_CategoryId");
migrationBuilder.RenameIndex(
name: "IX_AccountAccountCategories_AccountId",
table: "AccountAccountCategory",
newName: "IX_AccountAccountCategory_AccountId");
migrationBuilder.AddPrimaryKey(
name: "PK_AccountCategory",
table: "AccountCategory",
column: "Id");
migrationBuilder.AddPrimaryKey(
name: "PK_AccountAccountCategory",
table: "AccountAccountCategory",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_AccountAccountCategory_AccountCategory_AccountId",
table: "AccountAccountCategory",
column: "AccountId",
principalTable: "AccountCategory",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AccountAccountCategory_Accounts_CategoryId",
table: "AccountAccountCategory",
column: "CategoryId",
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}