From 8bcb2381a061ca1783e87b65f5a7992b4fb971af Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sun, 15 Dec 2019 21:58:16 +0900 Subject: [PATCH 1/2] Comment code to generate MySql migration scripts --- BTCPayServer.Data/Data/ApplicationDbContext.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/BTCPayServer.Data/Data/ApplicationDbContext.cs b/BTCPayServer.Data/Data/ApplicationDbContext.cs index d68f4f240..e4425251f 100644 --- a/BTCPayServer.Data/Data/ApplicationDbContext.cs +++ b/BTCPayServer.Data/Data/ApplicationDbContext.cs @@ -9,10 +9,23 @@ namespace BTCPayServer.Data { public class ApplicationDbContext : IdentityDbContext { + //public ApplicationDbContext(): base(CreateMySql()) + //{ + + //} + + //private static DbContextOptions CreateMySql() + //{ + // return new DbContextOptionsBuilder() + // .UseMySql("Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;") + // .Options; + //} + public ApplicationDbContext() { } + public ApplicationDbContext(DbContextOptions options) : base(options) { From 8e00e6d8e3f79bf13ef0ab4617f71b4a11f93301 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 23 Dec 2019 14:56:21 +0900 Subject: [PATCH 2/2] Make sure that varchar(255) is used for mysql migration scripts --- .../Migrations/20170913143004_Init.cs | 35 ++++++++++--------- .../Migrations/20170926073744_Settings.cs | 3 +- ...0170926084408_RequiresEmailConfirmation.cs | 1 + .../20171006013443_AddressMapping.cs | 5 +-- .../Migrations/20171010082424_Tokens.cs | 9 ++--- .../20171012020112_PendingInvoices.cs | 3 +- .../Migrations/20171023101754_StoreBlob.cs | 1 + .../20171024163354_RenewUsedAddresses.cs | 3 +- .../20171105235734_PaymentAccounted.cs | 1 + .../20171221054550_AltcoinSupport.cs | 1 + .../20180106095215_DerivationStrategies.cs | 1 + .../20180109021122_defaultcrypto.cs | 1 + .../Migrations/20180114123253_events.cs | 5 +-- .../Migrations/20180402095640_appdata.cs | 5 +-- .../Migrations/20180429083930_legacyapikey.cs | 1 + .../20180719095626_CanDeleteStores.cs | 1 + .../20190121133309_AddPaymentRequests.cs | 5 +-- .../Migrations/20190219032533_AppsTagging.cs | 1 + .../20190225091644_AddOpenIddict.cs | 17 ++++----- .../Migrations/20190324141717_AddFiles.cs | 5 +-- .../20190425081749_AddU2fDevices.cs | 5 +-- .../20190701082105_sort_paymentrequests.cs | 1 + .../Migrations/20190802142637_WalletData.cs | 7 ++-- BTCPayServer.Data/MigrationsExtensions.cs | 4 +++ 24 files changed, 74 insertions(+), 47 deletions(-) diff --git a/BTCPayServer.Data/Migrations/20170913143004_Init.cs b/BTCPayServer.Data/Migrations/20170913143004_Init.cs index cb85dd7d4..e77143dac 100644 --- a/BTCPayServer.Data/Migrations/20170913143004_Init.cs +++ b/BTCPayServer.Data/Migrations/20170913143004_Init.cs @@ -12,11 +12,12 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "AspNetRoles", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), ConcurrencyStamp = table.Column(nullable: true), Name = table.Column(maxLength: 256, nullable: true), NormalizedName = table.Column(maxLength: 256, nullable: true) @@ -30,7 +31,7 @@ namespace BTCPayServer.Migrations name: "AspNetUsers", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), AccessFailedCount = table.Column(nullable: false), ConcurrencyStamp = table.Column(nullable: true), Email = table.Column(maxLength: 256, nullable: true), @@ -55,7 +56,7 @@ namespace BTCPayServer.Migrations name: "Stores", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), DerivationStrategy = table.Column(nullable: true), SpeedPolicy = table.Column(nullable: false), StoreCertificate = table.Column(nullable: true), @@ -75,7 +76,7 @@ namespace BTCPayServer.Migrations .Annotation("Sqlite:Autoincrement", true), ClaimType = table.Column(nullable: true), ClaimValue = table.Column(nullable: true), - RoleId = table.Column(nullable: false) + RoleId = table.Column(nullable: false, maxLength: maxLength) }, constraints: table => { @@ -96,7 +97,7 @@ namespace BTCPayServer.Migrations .Annotation("Sqlite:Autoincrement", true), ClaimType = table.Column(nullable: true), ClaimValue = table.Column(nullable: true), - UserId = table.Column(nullable: false) + UserId = table.Column(nullable: false, maxLength: maxLength) }, constraints: table => { @@ -116,7 +117,7 @@ namespace BTCPayServer.Migrations LoginProvider = table.Column(nullable: false), ProviderKey = table.Column(nullable: false), ProviderDisplayName = table.Column(nullable: true), - UserId = table.Column(nullable: false) + UserId = table.Column(nullable: false, maxLength: maxLength) }, constraints: table => { @@ -133,8 +134,8 @@ namespace BTCPayServer.Migrations name: "AspNetUserRoles", columns: table => new { - UserId = table.Column(nullable: false), - RoleId = table.Column(nullable: false) + UserId = table.Column(nullable: false, maxLength: maxLength), + RoleId = table.Column(nullable: false, maxLength: maxLength) }, constraints: table => { @@ -157,7 +158,7 @@ namespace BTCPayServer.Migrations name: "AspNetUserTokens", columns: table => new { - UserId = table.Column(nullable: false), + UserId = table.Column(nullable: false, maxLength: maxLength), LoginProvider = table.Column(nullable: false), Name = table.Column(nullable: false), Value = table.Column(nullable: true) @@ -177,7 +178,7 @@ namespace BTCPayServer.Migrations name: "Invoices", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Blob = table.Column(nullable: true), Created = table.Column(nullable: false), CustomerEmail = table.Column(nullable: true), @@ -185,7 +186,7 @@ namespace BTCPayServer.Migrations ItemCode = table.Column(nullable: true), OrderId = table.Column(nullable: true), Status = table.Column(nullable: true), - StoreDataId = table.Column(nullable: true) + StoreDataId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { @@ -202,8 +203,8 @@ namespace BTCPayServer.Migrations name: "UserStore", columns: table => new { - ApplicationUserId = table.Column(nullable: false), - StoreDataId = table.Column(nullable: false), + ApplicationUserId = table.Column(nullable: false, maxLength: maxLength), + StoreDataId = table.Column(nullable: false, maxLength: maxLength), Role = table.Column(nullable: true) }, constraints: table => @@ -227,9 +228,9 @@ namespace BTCPayServer.Migrations name: "Payments", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Blob = table.Column(nullable: true), - InvoiceDataId = table.Column(nullable: true) + InvoiceDataId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { @@ -246,9 +247,9 @@ namespace BTCPayServer.Migrations name: "RefundAddresses", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Blob = table.Column(nullable: true), - InvoiceDataId = table.Column(nullable: true) + InvoiceDataId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { diff --git a/BTCPayServer.Data/Migrations/20170926073744_Settings.cs b/BTCPayServer.Data/Migrations/20170926073744_Settings.cs index 11d74400d..dc32f92e8 100644 --- a/BTCPayServer.Data/Migrations/20170926073744_Settings.cs +++ b/BTCPayServer.Data/Migrations/20170926073744_Settings.cs @@ -12,11 +12,12 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "Settings", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Value = table.Column(nullable: true) }, constraints: table => diff --git a/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs b/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs index c7964ee75..31202b508 100644 --- a/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs +++ b/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "RequiresEmailConfirmation", table: "AspNetUsers", diff --git a/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs b/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs index dea0c8a37..d0b82a283 100644 --- a/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs +++ b/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs @@ -12,12 +12,13 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "AddressInvoices", columns: table => new { - Address = table.Column(nullable: false), - InvoiceDataId = table.Column(nullable: true) + Address = table.Column(nullable: false, maxLength: this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)512 : null), + InvoiceDataId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { diff --git a/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs b/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs index 83910a2f9..1e46a7a66 100644 --- a/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs +++ b/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs @@ -12,17 +12,18 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "PairedSINData", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Facade = table.Column(nullable: true), Label = table.Column(nullable: true), Name = table.Column(nullable: true), PairingTime = table.Column(nullable: false), SIN = table.Column(nullable: true), - StoreDataId = table.Column(nullable: true) + StoreDataId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { @@ -33,14 +34,14 @@ namespace BTCPayServer.Migrations name: "PairingCodes", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), DateCreated = table.Column(nullable: false), Expiration = table.Column(nullable: false), Facade = table.Column(nullable: true), Label = table.Column(nullable: true), Name = table.Column(nullable: true), SIN = table.Column(nullable: true), - StoreDataId = table.Column(nullable: true), + StoreDataId = table.Column(nullable: true, maxLength: maxLength), TokenValue = table.Column(nullable: true) }, constraints: table => diff --git a/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs b/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs index bc9780f98..89f9f2e79 100644 --- a/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs +++ b/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; if (this.SupportDropColumn(migrationBuilder.ActiveProvider)) { migrationBuilder.DropColumn( @@ -26,7 +27,7 @@ namespace BTCPayServer.Migrations name: "PendingInvoices", columns: table => new { - Id = table.Column(nullable: false) + Id = table.Column(nullable: false, maxLength: maxLength) }, constraints: table => { diff --git a/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs b/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs index a0b59c199..33741c9eb 100644 --- a/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs +++ b/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "StoreBlob", table: "Stores", diff --git a/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs b/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs index c3628c86c..2f75e139d 100644 --- a/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs +++ b/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "CreatedTime", table: "AddressInvoices", @@ -21,7 +22,7 @@ namespace BTCPayServer.Migrations name: "HistoricalAddressInvoices", columns: table => new { - InvoiceDataId = table.Column(nullable: false), + InvoiceDataId = table.Column(nullable: false, maxLength: maxLength), Address = table.Column(nullable: false), Assigned = table.Column(nullable: false), UnAssigned = table.Column(nullable: true) diff --git a/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs b/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs index b300a7303..752c28387 100644 --- a/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs +++ b/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "Accounted", table: "Payments", diff --git a/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs b/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs index 5b0e73960..a5f25aea8 100644 --- a/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs +++ b/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "CryptoCode", table: "HistoricalAddressInvoices", diff --git a/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs b/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs index 8b2d278fb..49ab152a1 100644 --- a/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs +++ b/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "DerivationStrategies", table: "Stores", diff --git a/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs b/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs index 40900d93b..bb7502831 100644 --- a/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs +++ b/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "DefaultCrypto", table: "Stores", diff --git a/BTCPayServer.Data/Migrations/20180114123253_events.cs b/BTCPayServer.Data/Migrations/20180114123253_events.cs index 447dcd817..cdee7ffb3 100644 --- a/BTCPayServer.Data/Migrations/20180114123253_events.cs +++ b/BTCPayServer.Data/Migrations/20180114123253_events.cs @@ -12,12 +12,13 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "InvoiceEvents", columns: table => new { - InvoiceDataId = table.Column(nullable: false), - UniqueId = table.Column(nullable: false), + InvoiceDataId = table.Column(nullable: false, maxLength: maxLength), + UniqueId = table.Column(nullable: false, maxLength: maxLength), Message = table.Column(nullable: true), Timestamp = table.Column(nullable: false) }, diff --git a/BTCPayServer.Data/Migrations/20180402095640_appdata.cs b/BTCPayServer.Data/Migrations/20180402095640_appdata.cs index c6af520d1..e442e05ee 100644 --- a/BTCPayServer.Data/Migrations/20180402095640_appdata.cs +++ b/BTCPayServer.Data/Migrations/20180402095640_appdata.cs @@ -12,16 +12,17 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "Apps", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), AppType = table.Column(nullable: true), Created = table.Column(nullable: false), Name = table.Column(nullable: true), Settings = table.Column(nullable: true), - StoreDataId = table.Column(nullable: true) + StoreDataId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { diff --git a/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs b/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs index 024cd60b3..fc3d710b1 100644 --- a/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs +++ b/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs @@ -12,6 +12,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "ApiKeys", columns: table => new diff --git a/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs b/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs index bfa60ba83..33620c799 100644 --- a/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs +++ b/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs @@ -10,6 +10,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; if (this.SupportDropForeignKey(migrationBuilder.ActiveProvider)) { migrationBuilder.DropForeignKey( diff --git a/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs b/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs index c021fb361..3a6571ab6 100644 --- a/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs +++ b/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs @@ -11,12 +11,13 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "PaymentRequests", columns: table => new { - Id = table.Column(nullable: false), - StoreDataId = table.Column(nullable: true), + Id = table.Column(nullable: false, maxLength: maxLength), + StoreDataId = table.Column(nullable: true, maxLength: maxLength), Status = table.Column(nullable: false), Blob = table.Column(nullable: true) }, diff --git a/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs b/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs index 2fb837af4..2eb8b0cf2 100644 --- a/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs +++ b/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs @@ -10,6 +10,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "TagAllInvoices", table: "Apps", diff --git a/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs b/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs index 326f3ca96..2e75a3523 100644 --- a/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs +++ b/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs @@ -11,6 +11,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "OpenIddictApplications", columns: table => new @@ -20,13 +21,13 @@ namespace BTCPayServer.Migrations ConcurrencyToken = table.Column(maxLength: 50, nullable: true), ConsentType = table.Column(nullable: true), DisplayName = table.Column(nullable: true), - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Permissions = table.Column(nullable: true), PostLogoutRedirectUris = table.Column(nullable: true), Properties = table.Column(nullable: true), RedirectUris = table.Column(nullable: true), Type = table.Column(maxLength: 25, nullable: false), - ApplicationUserId = table.Column(nullable: true) + ApplicationUserId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { @@ -46,7 +47,7 @@ namespace BTCPayServer.Migrations ConcurrencyToken = table.Column(maxLength: 50, nullable: true), Description = table.Column(nullable: true), DisplayName = table.Column(nullable: true), - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Name = table.Column(maxLength: 200, nullable: false), Properties = table.Column(nullable: true), Resources = table.Column(nullable: true) @@ -60,9 +61,9 @@ namespace BTCPayServer.Migrations name: "OpenIddictAuthorizations", columns: table => new { - ApplicationId = table.Column(nullable: true), + ApplicationId = table.Column(nullable: true, maxLength: maxLength), ConcurrencyToken = table.Column(maxLength: 50, nullable: true), - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Properties = table.Column(nullable: true), Scopes = table.Column(nullable: true), Status = table.Column(maxLength: 25, nullable: false), @@ -84,12 +85,12 @@ namespace BTCPayServer.Migrations name: "OpenIddictTokens", columns: table => new { - ApplicationId = table.Column(nullable: true), - AuthorizationId = table.Column(nullable: true), + ApplicationId = table.Column(nullable: true, maxLength: maxLength), + AuthorizationId = table.Column(nullable: true, maxLength: maxLength), ConcurrencyToken = table.Column(maxLength: 50, nullable: true), CreationDate = table.Column(nullable: true), ExpirationDate = table.Column(nullable: true), - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Payload = table.Column(nullable: true), Properties = table.Column(nullable: true), ReferenceId = table.Column(maxLength: 100, nullable: true), diff --git a/BTCPayServer.Data/Migrations/20190324141717_AddFiles.cs b/BTCPayServer.Data/Migrations/20190324141717_AddFiles.cs index 105d17eaa..ebc973bd5 100644 --- a/BTCPayServer.Data/Migrations/20190324141717_AddFiles.cs +++ b/BTCPayServer.Data/Migrations/20190324141717_AddFiles.cs @@ -11,15 +11,16 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "Files", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), FileName = table.Column(nullable: true), StorageFileName = table.Column(nullable: true), Timestamp = table.Column(nullable: false), - ApplicationUserId = table.Column(nullable: true) + ApplicationUserId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { diff --git a/BTCPayServer.Data/Migrations/20190425081749_AddU2fDevices.cs b/BTCPayServer.Data/Migrations/20190425081749_AddU2fDevices.cs index 56df61156..9579b8c9e 100644 --- a/BTCPayServer.Data/Migrations/20190425081749_AddU2fDevices.cs +++ b/BTCPayServer.Data/Migrations/20190425081749_AddU2fDevices.cs @@ -11,6 +11,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; if (this.SupportDropColumn(migrationBuilder.ActiveProvider)) { migrationBuilder.DropColumn( @@ -22,13 +23,13 @@ namespace BTCPayServer.Migrations name: "U2FDevices", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Name = table.Column(nullable: true), KeyHandle = table.Column(nullable: false), PublicKey = table.Column(nullable: false), AttestationCert = table.Column(nullable: false), Counter = table.Column(nullable: false), - ApplicationUserId = table.Column(nullable: true) + ApplicationUserId = table.Column(nullable: true, maxLength: maxLength) }, constraints: table => { diff --git a/BTCPayServer.Data/Migrations/20190701082105_sort_paymentrequests.cs b/BTCPayServer.Data/Migrations/20190701082105_sort_paymentrequests.cs index acc290dd4..468ceb2e4 100644 --- a/BTCPayServer.Data/Migrations/20190701082105_sort_paymentrequests.cs +++ b/BTCPayServer.Data/Migrations/20190701082105_sort_paymentrequests.cs @@ -11,6 +11,7 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.AddColumn( name: "Created", table: "PaymentRequests", diff --git a/BTCPayServer.Data/Migrations/20190802142637_WalletData.cs b/BTCPayServer.Data/Migrations/20190802142637_WalletData.cs index fa600e54c..df2238d22 100644 --- a/BTCPayServer.Data/Migrations/20190802142637_WalletData.cs +++ b/BTCPayServer.Data/Migrations/20190802142637_WalletData.cs @@ -11,11 +11,12 @@ namespace BTCPayServer.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null; migrationBuilder.CreateTable( name: "Wallets", columns: table => new { - Id = table.Column(nullable: false), + Id = table.Column(nullable: false, maxLength: maxLength), Blob = table.Column(nullable: true) }, constraints: table => @@ -27,8 +28,8 @@ namespace BTCPayServer.Migrations name: "WalletTransactions", columns: table => new { - WalletDataId = table.Column(nullable: false), - TransactionId = table.Column(nullable: false), + WalletDataId = table.Column(nullable: false, maxLength: maxLength), + TransactionId = table.Column(nullable: false, maxLength: maxLength), Labels = table.Column(nullable: true), Blob = table.Column(nullable: true) }, diff --git a/BTCPayServer.Data/MigrationsExtensions.cs b/BTCPayServer.Data/MigrationsExtensions.cs index 4a55466c0..163238b59 100644 --- a/BTCPayServer.Data/MigrationsExtensions.cs +++ b/BTCPayServer.Data/MigrationsExtensions.cs @@ -20,5 +20,9 @@ namespace BTCPayServer.Migrations { return facade.ProviderName != "Microsoft.EntityFrameworkCore.Sqlite"; } + public static bool IsMySql(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider) + { + return activeProvider == "Pomelo.EntityFrameworkCore.MySql"; + } } }