cf439c5006
continuous-integration/drone/pr Build is passing
Resolved mediator source geenrator conflict with tests
109 lines
4.4 KiB
C#
109 lines
4.4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace LiteCharms.Features.MidrandBooks.Postgres.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public sealed partial class AddedPaymentGatewayLedger : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Ledger_Gateways_PaymentGatewayId",
|
|
table: "Ledger");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Ledger_PaymentGatewayId",
|
|
table: "Ledger");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "PaymentGatewayId",
|
|
table: "Ledger");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "PaymentGatewayReference",
|
|
table: "Ledger",
|
|
newName: "MerchantPaymentId");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "GatewayLedger",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
CustomerEmail = table.Column<string>(type: "text", nullable: true),
|
|
OrderId = table.Column<long>(type: "bigint", nullable: false),
|
|
PaymentId = table.Column<long>(type: "bigint", nullable: false),
|
|
MerchantPaymentId = table.Column<string>(type: "text", nullable: true),
|
|
PayfastPaymentId = table.Column<string>(type: "text", nullable: false),
|
|
PaymentStatus = table.Column<string>(type: "text", nullable: true),
|
|
AmountGross = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
AmountFee = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
|
|
AmountNet = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_GatewayLedger", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_GatewayLedger_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_GatewayLedger_Payments_PaymentId",
|
|
column: x => x.PaymentId,
|
|
principalTable: "Payments",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GatewayLedger_OrderId",
|
|
table: "GatewayLedger",
|
|
column: "OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GatewayLedger_PaymentId",
|
|
table: "GatewayLedger",
|
|
column: "PaymentId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "GatewayLedger");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "MerchantPaymentId",
|
|
table: "Ledger",
|
|
newName: "PaymentGatewayReference");
|
|
|
|
migrationBuilder.AddColumn<long>(
|
|
name: "PaymentGatewayId",
|
|
table: "Ledger",
|
|
type: "bigint",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Ledger_PaymentGatewayId",
|
|
table: "Ledger",
|
|
column: "PaymentGatewayId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Ledger_Gateways_PaymentGatewayId",
|
|
table: "Ledger",
|
|
column: "PaymentGatewayId",
|
|
principalTable: "Gateways",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
}
|
|
}
|