From caca8e81c235a0340c866a1a089c3e7e34944081 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 12 Oct 2017 16:41:11 +0900 Subject: [PATCH] Do not drop column for sqlite --- BTCPayServer/BTCPayServer.csproj | 2 +- .../20171012020112_PendingInvoices.cs | 77 ++++++++++--------- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 307091710..e5d07ab78 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.0 - 1.0.0.7 + 1.0.0.8 diff --git a/BTCPayServer/Migrations/20171012020112_PendingInvoices.cs b/BTCPayServer/Migrations/20171012020112_PendingInvoices.cs index 99453ad00..47ff49392 100644 --- a/BTCPayServer/Migrations/20171012020112_PendingInvoices.cs +++ b/BTCPayServer/Migrations/20171012020112_PendingInvoices.cs @@ -4,44 +4,51 @@ using System.Collections.Generic; namespace BTCPayServer.Migrations { - public partial class PendingInvoices : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Name", - table: "PairingCodes"); + public partial class PendingInvoices : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + if(SupportDropColumn(migrationBuilder.ActiveProvider)) + { + migrationBuilder.DropColumn( + name: "Name", + table: "PairingCodes"); - migrationBuilder.DropColumn( - name: "Name", - table: "PairedSINData"); + migrationBuilder.DropColumn( + name: "Name", + table: "PairedSINData"); + } + migrationBuilder.CreateTable( + name: "PendingInvoices", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PendingInvoices", x => x.Id); + }); + } - migrationBuilder.CreateTable( - name: "PendingInvoices", - columns: table => new - { - Id = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_PendingInvoices", x => x.Id); - }); - } + private bool SupportDropColumn(string activeProvider) + { + return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite"; + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "PendingInvoices"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "PendingInvoices"); - migrationBuilder.AddColumn( - name: "Name", - table: "PairingCodes", - nullable: true); + migrationBuilder.AddColumn( + name: "Name", + table: "PairingCodes", + nullable: true); - migrationBuilder.AddColumn( - name: "Name", - table: "PairedSINData", - nullable: true); - } - } + migrationBuilder.AddColumn( + name: "Name", + table: "PairedSINData", + nullable: true); + } + } }