using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DatabaseImplement.Migrations
{
///
public partial class sale : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn(
name: "Description",
table: "Products",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn(
name: "Category",
table: "Products",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AddColumn(
name: "SaleId",
table: "Products",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "Sales",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
Category = table.Column(type: "text", nullable: true),
Description = table.Column(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");
}
///
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(
name: "Description",
table: "Products",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn(
name: "Category",
table: "Products",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
}
}