domBudg/back/Infrastructure/Migrations/20241126185002_AddChangeRecord.cs

60 lines
2.2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddChangeRecord : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ChangeRecords",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Sum = table.Column<decimal>(type: "numeric", nullable: false),
ChangedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
SpendingGroupId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChangeRecords", x => x.Id);
table.ForeignKey(
name: "FK_ChangeRecords_SpendingGroups_SpendingGroupId",
column: x => x.SpendingGroupId,
principalTable: "SpendingGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChangeRecords_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ChangeRecords_SpendingGroupId",
table: "ChangeRecords",
column: "SpendingGroupId");
migrationBuilder.CreateIndex(
name: "IX_ChangeRecords_UserId",
table: "ChangeRecords",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChangeRecords");
}
}
}