using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace vendorApproverBackend.Migrations
{
///
public partial class AddCertificationEntity : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_products_File_model_ImageId",
table: "products");
migrationBuilder.DropIndex(
name: "IX_products_ImageId",
table: "products");
migrationBuilder.DropColumn(
name: "cost",
table: "products");
migrationBuilder.DropColumn(
name: "expiry_date",
table: "products");
migrationBuilder.DropColumn(
name: "has_warranty",
table: "products");
migrationBuilder.DropColumn(
name: "is_featured",
table: "products");
migrationBuilder.DropColumn(
name: "name",
table: "products");
migrationBuilder.DropColumn(
name: "price",
table: "products");
migrationBuilder.DropColumn(
name: "quantity",
table: "products");
migrationBuilder.DropColumn(
name: "weight",
table: "products");
migrationBuilder.RenameColumn(
name: "description",
table: "products",
newName: "vendor_name");
migrationBuilder.RenameColumn(
name: "code",
table: "products",
newName: "sub_category");
migrationBuilder.RenameColumn(
name: "ImageId",
table: "products",
newName: "vendor_id");
migrationBuilder.AlterColumn(
name: "category",
table: "products",
type: "text",
nullable: true,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AddColumn(
name: "prequalification_request_id",
table: "products",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn(
name: "product_city",
table: "products",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "product_country",
table: "products",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "product_desc",
table: "products",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "product_name",
table: "products",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "product_type",
table: "products",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "sku",
table: "products",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "timestmp",
table: "products",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.CreateTable(
name: "certifications",
columns: table => new
{
id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
certification_number = table.Column(type: "text", nullable: false),
supplier_name = table.Column(type: "text", nullable: false),
supplier_id = table.Column(type: "bigint", nullable: false),
certification_type = table.Column(type: "text", nullable: false),
issue_date = table.Column(type: "timestamp with time zone", nullable: false),
expiry_date = table.Column(type: "timestamp with time zone", nullable: false),
status = table.Column(type: "integer", nullable: false),
verified_by_user_id = table.Column(type: "bigint", nullable: false),
prequalification_request_id = table.Column(type: "bigint", nullable: false),
timestmp = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_certifications", x => x.id);
table.ForeignKey(
name: "FK_certifications_PrequalificationRequests_prequalification_re~",
column: x => x.prequalification_request_id,
principalTable: "PrequalificationRequests",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_certifications_users_table_verified_by_user_id",
column: x => x.verified_by_user_id,
principalTable: "users_table",
principalColumn: "user_id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_products_prequalification_request_id",
table: "products",
column: "prequalification_request_id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_certifications_prequalification_request_id",
table: "certifications",
column: "prequalification_request_id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_certifications_verified_by_user_id",
table: "certifications",
column: "verified_by_user_id");
migrationBuilder.AddForeignKey(
name: "FK_products_PrequalificationRequests_prequalification_request_~",
table: "products",
column: "prequalification_request_id",
principalTable: "PrequalificationRequests",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_products_PrequalificationRequests_prequalification_request_~",
table: "products");
migrationBuilder.DropTable(
name: "certifications");
migrationBuilder.DropIndex(
name: "IX_products_prequalification_request_id",
table: "products");
migrationBuilder.DropColumn(
name: "prequalification_request_id",
table: "products");
migrationBuilder.DropColumn(
name: "product_city",
table: "products");
migrationBuilder.DropColumn(
name: "product_country",
table: "products");
migrationBuilder.DropColumn(
name: "product_desc",
table: "products");
migrationBuilder.DropColumn(
name: "product_name",
table: "products");
migrationBuilder.DropColumn(
name: "product_type",
table: "products");
migrationBuilder.DropColumn(
name: "sku",
table: "products");
migrationBuilder.DropColumn(
name: "timestmp",
table: "products");
migrationBuilder.RenameColumn(
name: "vendor_name",
table: "products",
newName: "description");
migrationBuilder.RenameColumn(
name: "vendor_id",
table: "products",
newName: "ImageId");
migrationBuilder.RenameColumn(
name: "sub_category",
table: "products",
newName: "code");
migrationBuilder.AlterColumn(
name: "category",
table: "products",
type: "integer",
nullable: true,
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AddColumn(
name: "cost",
table: "products",
type: "double precision",
nullable: true);
migrationBuilder.AddColumn(
name: "expiry_date",
table: "products",
type: "timestamp with time zone",
nullable: true);
migrationBuilder.AddColumn(
name: "has_warranty",
table: "products",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn(
name: "is_featured",
table: "products",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn(
name: "name",
table: "products",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn(
name: "price",
table: "products",
type: "double precision",
nullable: true);
migrationBuilder.AddColumn(
name: "quantity",
table: "products",
type: "double precision",
nullable: true);
migrationBuilder.AddColumn(
name: "weight",
table: "products",
type: "double precision",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_products_ImageId",
table: "products",
column: "ImageId");
migrationBuilder.AddForeignKey(
name: "FK_products_File_model_ImageId",
table: "products",
column: "ImageId",
principalTable: "File_model",
principalColumn: "id");
}
}
}