PIAPS_CW/DatabaseImplement/Migrations/20240714214732_sale.cs

102 lines
3.1 KiB
C#
Raw Normal View History

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class sale : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Products",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Category",
table: "Products",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AddColumn<Guid>(
name: "SaleId",
table: "Products",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "Sales",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Category = table.Column<string>(type: "text", nullable: true),
Description = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sales", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Products_SaleId",
table: "Products",
column: "SaleId");
migrationBuilder.AddForeignKey(
name: "FK_Products_Sales_SaleId",
table: "Products",
column: "SaleId",
principalTable: "Sales",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Products_Sales_SaleId",
table: "Products");
migrationBuilder.DropTable(
name: "Sales");
migrationBuilder.DropIndex(
name: "IX_Products_SaleId",
table: "Products");
migrationBuilder.DropColumn(
name: "SaleId",
table: "Products");
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Products",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Category",
table: "Products",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
}
}