using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace vendorApproverBackend.Migrations { /// public partial class RequestRenewAllParts : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_certifications_PrequalificationRequests_prequalification_re~", table: "certifications"); migrationBuilder.DropForeignKey( name: "FK_certifications_users_table_verified_by_user_id", table: "certifications"); migrationBuilder.DropForeignKey( name: "FK_products_PrequalificationRequests_prequalification_request_~", table: "products"); migrationBuilder.RenameColumn( name: "update_tds_remark", table: "request_renews", newName: "UpdateTDSRemark"); migrationBuilder.RenameColumn( name: "reference_orders_remark", table: "request_renews", newName: "ReferenceOrdersRemark"); migrationBuilder.RenameColumn( name: "expired_product_certificate_remark", table: "request_renews", newName: "ExpiredProductCertificateRemark"); migrationBuilder.RenameColumn( name: "approved_design_remark", table: "request_renews", newName: "ApprovedDesignRemark"); migrationBuilder.AddColumn( name: "ClarificationId", table: "request_renews", type: "bigint", nullable: true); migrationBuilder.AddColumn( name: "FinalDecisionId", table: "request_renews", type: "bigint", nullable: true); migrationBuilder.AddColumn( name: "Part2EvaluationId", table: "request_renews", type: "bigint", nullable: true); migrationBuilder.AddColumn( name: "Part3DecisionId", table: "request_renews", type: "bigint", nullable: true); migrationBuilder.AddColumn( name: "PaymentId", table: "request_renews", type: "bigint", nullable: true); migrationBuilder.AlterColumn( name: "status", table: "notificationmodel", type: "integer", nullable: false, oldClrType: typeof(string), oldType: "text"); migrationBuilder.AlterColumn( name: "action", table: "notificationmodel", type: "integer", nullable: false, oldClrType: typeof(string), oldType: "text"); migrationBuilder.CreateTable( name: "renewal_final_decisions", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Decision = table.Column(type: "text", nullable: true), Comments = table.Column(type: "text", nullable: true), ReviewDate = table.Column(type: "timestamp with time zone", nullable: true), SupportingDocumentId = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_renewal_final_decisions", x => x.id); table.ForeignKey( name: "FK_renewal_final_decisions_File_model_SupportingDocumentId", column: x => x.SupportingDocumentId, principalTable: "File_model", principalColumn: "id"); }); migrationBuilder.CreateTable( name: "renewal_part2_evaluations", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), total_score = table.Column(type: "double precision", nullable: false), Criteria = table.Column(type: "jsonb", nullable: false) }, constraints: table => { table.PrimaryKey("PK_renewal_part2_evaluations", x => x.id); }); migrationBuilder.CreateTable( name: "renewal_part3_decisions", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Decision = table.Column(type: "text", nullable: true), Reason = table.Column(type: "text", nullable: true), DecidedBy = table.Column(type: "text", nullable: true), DecisionDate = table.Column(type: "timestamp with time zone", nullable: true), SupportingDocumentId = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_renewal_part3_decisions", x => x.id); table.ForeignKey( name: "FK_renewal_part3_decisions_File_model_SupportingDocumentId", column: x => x.SupportingDocumentId, principalTable: "File_model", principalColumn: "id"); }); migrationBuilder.CreateTable( name: "renewal_payments", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Amount = table.Column(type: "double precision", nullable: true), Currency = table.Column(type: "text", nullable: true), PaymentDate = table.Column(type: "timestamp with time zone", nullable: true), TransactionId = table.Column(type: "text", nullable: true), Status = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_renewal_payments", x => x.id); }); migrationBuilder.CreateTable( name: "renewal_vendor_responses", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ResponseDate = table.Column(type: "timestamp with time zone", nullable: true), Comments = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_renewal_vendor_responses", x => x.id); }); migrationBuilder.CreateTable( name: "renewal_clarifications", columns: table => new { id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RequestedBy = table.Column(type: "text", nullable: true), RequestedDate = table.Column(type: "timestamp with time zone", nullable: true), Comments = table.Column(type: "text", nullable: true), RequiredDocuments = table.Column>(type: "jsonb", nullable: false), VendorResponseId = table.Column(type: "bigint", nullable: true) }, constraints: table => { table.PrimaryKey("PK_renewal_clarifications", x => x.id); table.ForeignKey( name: "FK_renewal_clarifications_renewal_vendor_responses_VendorRespo~", column: x => x.VendorResponseId, principalTable: "renewal_vendor_responses", principalColumn: "id"); }); migrationBuilder.CreateTable( name: "vendor_response_files", columns: table => new { DocumentsId = table.Column(type: "bigint", nullable: false), VendorResponseId = table.Column(type: "bigint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_vendor_response_files", x => new { x.DocumentsId, x.VendorResponseId }); table.ForeignKey( name: "FK_vendor_response_files_File_model_DocumentsId", column: x => x.DocumentsId, principalTable: "File_model", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_vendor_response_files_renewal_vendor_responses_VendorRespon~", column: x => x.VendorResponseId, principalTable: "renewal_vendor_responses", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_request_renews_ClarificationId", table: "request_renews", column: "ClarificationId", unique: true); migrationBuilder.CreateIndex( name: "IX_request_renews_FinalDecisionId", table: "request_renews", column: "FinalDecisionId", unique: true); migrationBuilder.CreateIndex( name: "IX_request_renews_Part2EvaluationId", table: "request_renews", column: "Part2EvaluationId", unique: true); migrationBuilder.CreateIndex( name: "IX_request_renews_Part3DecisionId", table: "request_renews", column: "Part3DecisionId", unique: true); migrationBuilder.CreateIndex( name: "IX_request_renews_PaymentId", table: "request_renews", column: "PaymentId", unique: true); migrationBuilder.CreateIndex( name: "IX_renewal_clarifications_VendorResponseId", table: "renewal_clarifications", column: "VendorResponseId"); migrationBuilder.CreateIndex( name: "IX_renewal_final_decisions_SupportingDocumentId", table: "renewal_final_decisions", column: "SupportingDocumentId"); migrationBuilder.CreateIndex( name: "IX_renewal_part3_decisions_SupportingDocumentId", table: "renewal_part3_decisions", column: "SupportingDocumentId"); migrationBuilder.CreateIndex( name: "IX_vendor_response_files_VendorResponseId", table: "vendor_response_files", column: "VendorResponseId"); migrationBuilder.AddForeignKey( name: "FK_certifications_PrequalificationRequests_prequalification_re~", table: "certifications", column: "prequalification_request_id", principalTable: "PrequalificationRequests", principalColumn: "id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_certifications_users_table_verified_by_user_id", table: "certifications", column: "verified_by_user_id", principalTable: "users_table", principalColumn: "user_id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_products_PrequalificationRequests_prequalification_request_~", table: "products", column: "prequalification_request_id", principalTable: "PrequalificationRequests", principalColumn: "id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_request_renews_renewal_clarifications_ClarificationId", table: "request_renews", column: "ClarificationId", principalTable: "renewal_clarifications", principalColumn: "id"); migrationBuilder.AddForeignKey( name: "FK_request_renews_renewal_final_decisions_FinalDecisionId", table: "request_renews", column: "FinalDecisionId", principalTable: "renewal_final_decisions", principalColumn: "id"); migrationBuilder.AddForeignKey( name: "FK_request_renews_renewal_part2_evaluations_Part2EvaluationId", table: "request_renews", column: "Part2EvaluationId", principalTable: "renewal_part2_evaluations", principalColumn: "id"); migrationBuilder.AddForeignKey( name: "FK_request_renews_renewal_part3_decisions_Part3DecisionId", table: "request_renews", column: "Part3DecisionId", principalTable: "renewal_part3_decisions", principalColumn: "id"); migrationBuilder.AddForeignKey( name: "FK_request_renews_renewal_payments_PaymentId", table: "request_renews", column: "PaymentId", principalTable: "renewal_payments", principalColumn: "id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_certifications_PrequalificationRequests_prequalification_re~", table: "certifications"); migrationBuilder.DropForeignKey( name: "FK_certifications_users_table_verified_by_user_id", table: "certifications"); migrationBuilder.DropForeignKey( name: "FK_products_PrequalificationRequests_prequalification_request_~", table: "products"); migrationBuilder.DropForeignKey( name: "FK_request_renews_renewal_clarifications_ClarificationId", table: "request_renews"); migrationBuilder.DropForeignKey( name: "FK_request_renews_renewal_final_decisions_FinalDecisionId", table: "request_renews"); migrationBuilder.DropForeignKey( name: "FK_request_renews_renewal_part2_evaluations_Part2EvaluationId", table: "request_renews"); migrationBuilder.DropForeignKey( name: "FK_request_renews_renewal_part3_decisions_Part3DecisionId", table: "request_renews"); migrationBuilder.DropForeignKey( name: "FK_request_renews_renewal_payments_PaymentId", table: "request_renews"); migrationBuilder.DropTable( name: "renewal_clarifications"); migrationBuilder.DropTable( name: "renewal_final_decisions"); migrationBuilder.DropTable( name: "renewal_part2_evaluations"); migrationBuilder.DropTable( name: "renewal_part3_decisions"); migrationBuilder.DropTable( name: "renewal_payments"); migrationBuilder.DropTable( name: "vendor_response_files"); migrationBuilder.DropTable( name: "renewal_vendor_responses"); migrationBuilder.DropIndex( name: "IX_request_renews_ClarificationId", table: "request_renews"); migrationBuilder.DropIndex( name: "IX_request_renews_FinalDecisionId", table: "request_renews"); migrationBuilder.DropIndex( name: "IX_request_renews_Part2EvaluationId", table: "request_renews"); migrationBuilder.DropIndex( name: "IX_request_renews_Part3DecisionId", table: "request_renews"); migrationBuilder.DropIndex( name: "IX_request_renews_PaymentId", table: "request_renews"); migrationBuilder.DropColumn( name: "ClarificationId", table: "request_renews"); migrationBuilder.DropColumn( name: "FinalDecisionId", table: "request_renews"); migrationBuilder.DropColumn( name: "Part2EvaluationId", table: "request_renews"); migrationBuilder.DropColumn( name: "Part3DecisionId", table: "request_renews"); migrationBuilder.DropColumn( name: "PaymentId", table: "request_renews"); migrationBuilder.RenameColumn( name: "UpdateTDSRemark", table: "request_renews", newName: "update_tds_remark"); migrationBuilder.RenameColumn( name: "ReferenceOrdersRemark", table: "request_renews", newName: "reference_orders_remark"); migrationBuilder.RenameColumn( name: "ExpiredProductCertificateRemark", table: "request_renews", newName: "expired_product_certificate_remark"); migrationBuilder.RenameColumn( name: "ApprovedDesignRemark", table: "request_renews", newName: "approved_design_remark"); migrationBuilder.AlterColumn( name: "status", table: "notificationmodel", type: "text", nullable: false, oldClrType: typeof(int), oldType: "integer"); migrationBuilder.AlterColumn( name: "action", table: "notificationmodel", type: "text", nullable: false, oldClrType: typeof(int), oldType: "integer"); migrationBuilder.AddForeignKey( name: "FK_certifications_PrequalificationRequests_prequalification_re~", table: "certifications", column: "prequalification_request_id", principalTable: "PrequalificationRequests", principalColumn: "id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_certifications_users_table_verified_by_user_id", table: "certifications", column: "verified_by_user_id", principalTable: "users_table", principalColumn: "user_id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_products_PrequalificationRequests_prequalification_request_~", table: "products", column: "prequalification_request_id", principalTable: "PrequalificationRequests", principalColumn: "id", onDelete: ReferentialAction.Restrict); } } }