using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace vendorApproverBackend.Migrations
{
///
public partial class AddProductEntity : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "products",
columns: table => new
{
id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column(type: "text", nullable: false),
code = table.Column(type: "text", nullable: true),
description = table.Column(type: "text", nullable: true),
price = table.Column(type: "double precision", nullable: true),
cost = table.Column(type: "double precision", nullable: true),
quantity = table.Column(type: "double precision", nullable: true),
category = table.Column(type: "integer", nullable: true),
status = table.Column(type: "integer", nullable: true),
weight = table.Column(type: "double precision", nullable: true),
expiry_date = table.Column(type: "timestamp with time zone", nullable: true),
is_featured = table.Column(type: "boolean", nullable: false),
has_warranty = table.Column(type: "boolean", nullable: false),
ImageId = table.Column(type: "bigint", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_products", x => x.id);
table.ForeignKey(
name: "FK_products_File_model_ImageId",
column: x => x.ImageId,
principalTable: "File_model",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateIndex(
name: "IX_products_ImageId",
table: "products",
column: "ImageId",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "products");
}
}
}