drinkrate/DrinkRateAPI/Migrations/20250811180050_ProductCompanyTableBinding.cs
martinshoob e0ecd86288 Establish a one-to-one relationship
Define a one-to-one relationship between CompanyTable and ProductTable.

Correct a typo in the CompanyTable DbSet name within the ApplicationDbContext to ensure correct database mapping and operations.
2025-08-11 20:12:42 +02:00

63 lines
2 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DrinkRateAPI.Migrations
{
/// <inheritdoc />
public partial class ProductCompanyTableBinding : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CompanyTableId",
table: "ProductTable",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "ProductTableId",
table: "CompanyTables",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.CreateIndex(
name: "IX_ProductTable_CompanyTableId",
table: "ProductTable",
column: "CompanyTableId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_ProductTable_CompanyTables_CompanyTableId",
table: "ProductTable",
column: "CompanyTableId",
principalTable: "CompanyTables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ProductTable_CompanyTables_CompanyTableId",
table: "ProductTable");
migrationBuilder.DropIndex(
name: "IX_ProductTable_CompanyTableId",
table: "ProductTable");
migrationBuilder.DropColumn(
name: "CompanyTableId",
table: "ProductTable");
migrationBuilder.DropColumn(
name: "ProductTableId",
table: "CompanyTables");
}
}
}