Consolidate tables before release

This commit is contained in:
nicolas.dorier 2020-06-25 15:43:45 +09:00
parent 69b423edc8
commit ae9fae1f7d
No known key found for this signature in database
GPG key ID: 6618763EF09186FE
10 changed files with 218 additions and 1400 deletions

View file

@ -14,9 +14,11 @@ namespace BTCPayServer.Data
public string Id { get; set; }
public DateTimeOffset Created { get; set; }
[MaxLength(50)]
[Required]
public string ApplicationUserId { get; set; }
public ApplicationUser ApplicationUser { get; set; }
[MaxLength(100)]
[Required]
public string NotificationType { get; set; }
public bool Seen { get; set; }
public byte[] Blob { get; set; }

View file

@ -1,48 +0,0 @@
using System;
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200614002524_AddNotificationDataEntity")]
public partial class AddNotificationDataEntity : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Notifications",
columns: table => new
{
Id = table.Column<string>(maxLength: 36, nullable: false),
Created = table.Column<DateTimeOffset>(nullable: false),
ApplicationUserId = table.Column<string>(maxLength: 50, nullable: true),
NotificationType = table.Column<string>(maxLength: 100, nullable: true),
Seen = table.Column<bool>(nullable: false),
Blob = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Notifications", x => x.Id);
table.ForeignKey(
name: "FK_Notifications_AspNetUsers_ApplicationUserId",
column: x => x.ApplicationUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Notifications_ApplicationUserId",
table: "Notifications",
column: "ApplicationUserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Notifications");
}
}
}

View file

@ -1,92 +0,0 @@
using System;
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200623042347_pullpayments")]
public partial class pullpayments : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PullPayments",
columns: table => new
{
Id = table.Column<string>(maxLength: 30, nullable: false),
StoreId = table.Column<string>(maxLength: 50, nullable: true),
Period = table.Column<long>(nullable: true),
StartDate = table.Column<DateTimeOffset>(nullable: false),
EndDate = table.Column<DateTimeOffset>(nullable: true),
Archived = table.Column<bool>(nullable: false),
Blob = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PullPayments", x => x.Id);
table.ForeignKey(
name: "FK_PullPayments_Stores_StoreId",
column: x => x.StoreId,
principalTable: "Stores",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Payouts",
columns: table => new
{
Id = table.Column<string>(maxLength: 30, nullable: false),
Date = table.Column<DateTimeOffset>(nullable: false),
PullPaymentDataId = table.Column<string>(nullable: true),
State = table.Column<string>(maxLength: 20, nullable: false),
PaymentMethodId = table.Column<string>(maxLength: 20, nullable: false),
Destination = table.Column<string>(nullable: true),
Blob = table.Column<byte[]>(nullable: true),
Proof = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Payouts", x => x.Id);
table.ForeignKey(
name: "FK_Payouts_PullPayments_PullPaymentDataId",
column: x => x.PullPaymentDataId,
principalTable: "PullPayments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Payouts_Destination",
table: "Payouts",
column: "Destination",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Payouts_PullPaymentDataId",
table: "Payouts",
column: "PullPaymentDataId");
migrationBuilder.CreateIndex(
name: "IX_Payouts_State",
table: "Payouts",
column: "State");
migrationBuilder.CreateIndex(
name: "IX_PullPayments_StoreId",
table: "PullPayments",
column: "StoreId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Payouts");
migrationBuilder.DropTable(
name: "PullPayments");
}
}
}

View file

@ -1,49 +0,0 @@
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200624051926_invoicerefund")]
public partial class invoicerefund : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PullPaymentDataId",
table: "Invoices",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Invoices_PullPaymentDataId",
table: "Invoices",
column: "PullPaymentDataId");
if (this.SupportAddForeignKey(migrationBuilder.ActiveProvider))
{
migrationBuilder.AddForeignKey(
name: "FK_Invoices_PullPayments_PullPaymentDataId",
table: "Invoices",
column: "PullPaymentDataId",
principalTable: "PullPayments",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Invoices_PullPayments_PullPaymentDataId",
table: "Invoices");
migrationBuilder.DropIndex(
name: "IX_Invoices_PullPaymentDataId",
table: "Invoices");
migrationBuilder.DropColumn(
name: "PullPaymentDataId",
table: "Invoices");
}
}
}

View file

@ -1,45 +0,0 @@
using System;
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200625043042_removeoldrefund")]
public partial class removeoldrefund : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RefundAddresses");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "RefundAddresses",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Blob = table.Column<byte[]>(type: "BLOB", nullable: true),
InvoiceDataId = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RefundAddresses", x => x.Id);
table.ForeignKey(
name: "FK_RefundAddresses_Invoices_InvoiceDataId",
column: x => x.InvoiceDataId,
principalTable: "Invoices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_RefundAddresses_InvoiceDataId",
table: "RefundAddresses",
column: "InvoiceDataId");
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,45 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
public partial class refundinvoice2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Refunds",
columns: table => new
{
InvoiceDataId = table.Column<string>(nullable: false),
PullPaymentDataId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Refunds", x => new { x.InvoiceDataId, x.PullPaymentDataId });
table.ForeignKey(
name: "FK_Refunds_Invoices_InvoiceDataId",
column: x => x.InvoiceDataId,
principalTable: "Invoices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Refunds_PullPayments_PullPaymentDataId",
column: x => x.PullPaymentDataId,
principalTable: "PullPayments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Refunds_PullPaymentDataId",
table: "Refunds",
column: "PullPaymentDataId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Refunds");
}
}
}

View file

@ -1,81 +0,0 @@
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200625060941_refundinvoice3")]
public partial class refundinvoice3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
if (this.SupportDropForeignKey(migrationBuilder.ActiveProvider))
migrationBuilder.DropForeignKey(
name: "FK_Invoices_PullPayments_PullPaymentDataId",
table: "Invoices");
migrationBuilder.DropIndex(
name: "IX_Invoices_PullPaymentDataId",
table: "Invoices");
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
migrationBuilder.DropColumn(
name: "PullPaymentDataId",
table: "Invoices");
migrationBuilder.AddColumn<string>(
name: "CurrentRefundId",
table: "Invoices",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Invoices_Id_CurrentRefundId",
table: "Invoices",
columns: new[] { "Id", "CurrentRefundId" });
if (this.SupportAddForeignKey(migrationBuilder.ActiveProvider))
migrationBuilder.AddForeignKey(
name: "FK_Invoices_Refunds_Id_CurrentRefundId",
table: "Invoices",
columns: new[] { "Id", "CurrentRefundId" },
principalTable: "Refunds",
principalColumns: new[] { "InvoiceDataId", "PullPaymentDataId" },
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Invoices_Refunds_Id_CurrentRefundId",
table: "Invoices");
migrationBuilder.DropIndex(
name: "IX_Invoices_Id_CurrentRefundId",
table: "Invoices");
migrationBuilder.DropColumn(
name: "CurrentRefundId",
table: "Invoices");
migrationBuilder.AddColumn<string>(
name: "PullPaymentDataId",
table: "Invoices",
type: "TEXT",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Invoices_PullPaymentDataId",
table: "Invoices",
column: "PullPaymentDataId");
migrationBuilder.AddForeignKey(
name: "FK_Invoices_PullPayments_PullPaymentDataId",
table: "Invoices",
column: "PullPaymentDataId",
principalTable: "PullPayments",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

View file

@ -0,0 +1,212 @@
using System;
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200625064111_refundnotificationpullpayments")]
public partial class refundnotificationpullpayments : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RefundAddresses");
migrationBuilder.AddColumn<string>(
name: "CurrentRefundId",
table: "Invoices",
nullable: true);
migrationBuilder.CreateTable(
name: "Notifications",
columns: table => new
{
Id = table.Column<string>(maxLength: 36, nullable: false),
Created = table.Column<DateTimeOffset>(nullable: false),
ApplicationUserId = table.Column<string>(maxLength: 50, nullable: false),
NotificationType = table.Column<string>(maxLength: 100, nullable: false),
Seen = table.Column<bool>(nullable: false),
Blob = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Notifications", x => x.Id);
table.ForeignKey(
name: "FK_Notifications_AspNetUsers_ApplicationUserId",
column: x => x.ApplicationUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PullPayments",
columns: table => new
{
Id = table.Column<string>(maxLength: 30, nullable: false),
StoreId = table.Column<string>(maxLength: 50, nullable: true),
Period = table.Column<long>(nullable: true),
StartDate = table.Column<DateTimeOffset>(nullable: false),
EndDate = table.Column<DateTimeOffset>(nullable: true),
Archived = table.Column<bool>(nullable: false),
Blob = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_PullPayments", x => x.Id);
table.ForeignKey(
name: "FK_PullPayments_Stores_StoreId",
column: x => x.StoreId,
principalTable: "Stores",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Payouts",
columns: table => new
{
Id = table.Column<string>(maxLength: 30, nullable: false),
Date = table.Column<DateTimeOffset>(nullable: false),
PullPaymentDataId = table.Column<string>(nullable: true),
State = table.Column<string>(maxLength: 20, nullable: false),
PaymentMethodId = table.Column<string>(maxLength: 20, nullable: false),
Destination = table.Column<string>(nullable: true),
Blob = table.Column<byte[]>(nullable: true),
Proof = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Payouts", x => x.Id);
table.ForeignKey(
name: "FK_Payouts_PullPayments_PullPaymentDataId",
column: x => x.PullPaymentDataId,
principalTable: "PullPayments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Refunds",
columns: table => new
{
InvoiceDataId = table.Column<string>(nullable: false),
PullPaymentDataId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Refunds", x => new { x.InvoiceDataId, x.PullPaymentDataId });
table.ForeignKey(
name: "FK_Refunds_Invoices_InvoiceDataId",
column: x => x.InvoiceDataId,
principalTable: "Invoices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Refunds_PullPayments_PullPaymentDataId",
column: x => x.PullPaymentDataId,
principalTable: "PullPayments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Invoices_Id_CurrentRefundId",
table: "Invoices",
columns: new[] { "Id", "CurrentRefundId" });
migrationBuilder.CreateIndex(
name: "IX_Notifications_ApplicationUserId",
table: "Notifications",
column: "ApplicationUserId");
migrationBuilder.CreateIndex(
name: "IX_Payouts_Destination",
table: "Payouts",
column: "Destination",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Payouts_PullPaymentDataId",
table: "Payouts",
column: "PullPaymentDataId");
migrationBuilder.CreateIndex(
name: "IX_Payouts_State",
table: "Payouts",
column: "State");
migrationBuilder.CreateIndex(
name: "IX_PullPayments_StoreId",
table: "PullPayments",
column: "StoreId");
migrationBuilder.CreateIndex(
name: "IX_Refunds_PullPaymentDataId",
table: "Refunds",
column: "PullPaymentDataId");
if (this.SupportAddForeignKey(this.ActiveProvider))
migrationBuilder.AddForeignKey(
name: "FK_Invoices_Refunds_Id_CurrentRefundId",
table: "Invoices",
columns: new[] { "Id", "CurrentRefundId" },
principalTable: "Refunds",
principalColumns: new[] { "InvoiceDataId", "PullPaymentDataId" },
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Invoices_Refunds_Id_CurrentRefundId",
table: "Invoices");
migrationBuilder.DropTable(
name: "Notifications");
migrationBuilder.DropTable(
name: "Payouts");
migrationBuilder.DropTable(
name: "Refunds");
migrationBuilder.DropTable(
name: "PullPayments");
migrationBuilder.DropIndex(
name: "IX_Invoices_Id_CurrentRefundId",
table: "Invoices");
migrationBuilder.DropColumn(
name: "CurrentRefundId",
table: "Invoices");
migrationBuilder.CreateTable(
name: "RefundAddresses",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Blob = table.Column<byte[]>(type: "BLOB", nullable: true),
InvoiceDataId = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RefundAddresses", x => x.Id);
table.ForeignKey(
name: "FK_RefundAddresses_Invoices_InvoiceDataId",
column: x => x.InvoiceDataId,
principalTable: "Invoices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_RefundAddresses_InvoiceDataId",
table: "RefundAddresses",
column: "InvoiceDataId");
}
}
}

View file

@ -255,6 +255,7 @@ namespace BTCPayServer.Migrations
.HasMaxLength(36);
b.Property<string>("ApplicationUserId")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(50);
@ -265,6 +266,7 @@ namespace BTCPayServer.Migrations
.HasColumnType("TEXT");
b.Property<string>("NotificationType")
.IsRequired()
.HasColumnType("TEXT")
.HasMaxLength(100);
@ -876,7 +878,8 @@ namespace BTCPayServer.Migrations
b.HasOne("BTCPayServer.Data.ApplicationUser", "ApplicationUser")
.WithMany("Notifications")
.HasForeignKey("ApplicationUserId")
.OnDelete(DeleteBehavior.Cascade);
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("BTCPayServer.Data.PairedSINData", b =>