drinkrate/DrinkRateAPI/Migrations/20250809170131_ObjectHistory.cs
2025-08-09 19:05:02 +02:00

142 lines
6.7 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DrinkRateAPI.Migrations
{
/// <inheritdoc />
public partial class ObjectHistory : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "UpdateRecords",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserProfileId = table.Column<Guid>(type: "uuid", nullable: false),
UpdateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
DbCompanyId = table.Column<Guid>(type: "uuid", nullable: true),
DbCompanyRatingCompanyId = table.Column<Guid>(type: "uuid", nullable: true),
DbCompanyRatingUserProfileId = table.Column<Guid>(type: "uuid", nullable: true),
DbCompanyTableViewId = table.Column<Guid>(type: "uuid", nullable: true),
DbProductId = table.Column<Guid>(type: "uuid", nullable: true),
DbProductRatingProductId = table.Column<Guid>(type: "uuid", nullable: true),
DbProductRatingUserProfileId = table.Column<Guid>(type: "uuid", nullable: true),
DbProductTableViewId = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UpdateRecords", x => x.Id);
table.ForeignKey(
name: "FK_UpdateRecords_Companies_DbCompanyId",
column: x => x.DbCompanyId,
principalTable: "Companies",
principalColumn: "Id");
table.ForeignKey(
name: "FK_UpdateRecords_CompanyRatings_DbCompanyRatingUserProfileId_D~",
columns: x => new { x.DbCompanyRatingUserProfileId, x.DbCompanyRatingCompanyId },
principalTable: "CompanyRatings",
principalColumns: new[] { "UserProfileId", "CompanyId" });
table.ForeignKey(
name: "FK_UpdateRecords_CompanyTableViews_DbCompanyTableViewId",
column: x => x.DbCompanyTableViewId,
principalTable: "CompanyTableViews",
principalColumn: "Id");
table.ForeignKey(
name: "FK_UpdateRecords_ProductRating_DbProductRatingUserProfileId_Db~",
columns: x => new { x.DbProductRatingUserProfileId, x.DbProductRatingProductId },
principalTable: "ProductRating",
principalColumns: new[] { "UserProfileId", "ProductId" });
table.ForeignKey(
name: "FK_UpdateRecords_ProductTableView_DbProductTableViewId",
column: x => x.DbProductTableViewId,
principalTable: "ProductTableView",
principalColumn: "Id");
table.ForeignKey(
name: "FK_UpdateRecords_Product_DbProductId",
column: x => x.DbProductId,
principalTable: "Product",
principalColumn: "Id");
table.ForeignKey(
name: "FK_UpdateRecords_UserProfiles_UserProfileId",
column: x => x.UserProfileId,
principalTable: "UserProfiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UpdateRecordFieldChanges",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Field = table.Column<string>(type: "text", nullable: false),
OldValue = table.Column<string>(type: "text", nullable: false),
NewValue = table.Column<string>(type: "text", nullable: false),
DbUpdateRecordId = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UpdateRecordFieldChanges", x => x.Id);
table.ForeignKey(
name: "FK_UpdateRecordFieldChanges_UpdateRecords_DbUpdateRecordId",
column: x => x.DbUpdateRecordId,
principalTable: "UpdateRecords",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_UpdateRecordFieldChanges_DbUpdateRecordId",
table: "UpdateRecordFieldChanges",
column: "DbUpdateRecordId");
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_DbCompanyId",
table: "UpdateRecords",
column: "DbCompanyId");
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_DbCompanyRatingUserProfileId_DbCompanyRatingC~",
table: "UpdateRecords",
columns: new[] { "DbCompanyRatingUserProfileId", "DbCompanyRatingCompanyId" });
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_DbCompanyTableViewId",
table: "UpdateRecords",
column: "DbCompanyTableViewId");
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_DbProductId",
table: "UpdateRecords",
column: "DbProductId");
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_DbProductRatingUserProfileId_DbProductRatingP~",
table: "UpdateRecords",
columns: new[] { "DbProductRatingUserProfileId", "DbProductRatingProductId" });
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_DbProductTableViewId",
table: "UpdateRecords",
column: "DbProductTableViewId");
migrationBuilder.CreateIndex(
name: "IX_UpdateRecords_UserProfileId",
table: "UpdateRecords",
column: "UserProfileId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UpdateRecordFieldChanges");
migrationBuilder.DropTable(
name: "UpdateRecords");
}
}
}