diff --git a/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj b/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj
index 54a248353..544bab587 100644
--- a/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj
+++ b/BTCPayServer.Abstractions/BTCPayServer.Abstractions.csproj
@@ -33,9 +33,7 @@
-
-
diff --git a/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs b/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs
index 2849a29a5..d5ae67fbf 100644
--- a/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs
+++ b/BTCPayServer.Abstractions/Contracts/BaseDbContextFactory.cs
@@ -13,12 +13,12 @@ namespace BTCPayServer.Abstractions.Contracts
public abstract class BaseDbContextFactory where T : DbContext
{
private readonly IOptions _options;
- private readonly string _schemaPrefix;
+ private readonly string _migrationTableName;
- public BaseDbContextFactory(IOptions options, string schemaPrefix)
+ public BaseDbContextFactory(IOptions options, string migrationTableName)
{
_options = options;
- _schemaPrefix = schemaPrefix;
+ _migrationTableName = migrationTableName;
}
public abstract T CreateContext();
@@ -68,43 +68,16 @@ namespace BTCPayServer.Abstractions.Contracts
public void ConfigureBuilder(DbContextOptionsBuilder builder)
{
- switch (_options.Value.DatabaseType)
+ builder
+ .UseNpgsql(_options.Value.ConnectionString, o =>
{
- case DatabaseType.Sqlite:
- builder.UseSqlite(_options.Value.ConnectionString, o =>
- {
- if (!string.IsNullOrEmpty(_schemaPrefix))
- {
- o.MigrationsHistoryTable(_schemaPrefix);
- }
- });
- break;
- case DatabaseType.Postgres:
- builder
- .UseNpgsql(_options.Value.ConnectionString, o =>
- {
- o.EnableRetryOnFailure(10);
- o.SetPostgresVersion(12, 0);
- var mainSearchPath = GetSearchPath(_options.Value.ConnectionString);
- var schemaPrefix = string.IsNullOrEmpty(_schemaPrefix) ? "__EFMigrationsHistory" : _schemaPrefix;
- o.MigrationsHistoryTable(schemaPrefix, mainSearchPath);
- })
- .ReplaceService();
- break;
- case DatabaseType.MySQL:
- builder.UseMySql(_options.Value.ConnectionString, ServerVersion.AutoDetect(_options.Value.ConnectionString), o =>
- {
- o.EnableRetryOnFailure(10);
-
- if (!string.IsNullOrEmpty(_schemaPrefix))
- {
- o.MigrationsHistoryTable(_schemaPrefix);
- }
- });
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
+ o.EnableRetryOnFailure(10);
+ o.SetPostgresVersion(12, 0);
+ var mainSearchPath = GetSearchPath(_options.Value.ConnectionString);
+ var schemaPrefix = string.IsNullOrEmpty(_migrationTableName) ? "__EFMigrationsHistory" : _migrationTableName;
+ o.MigrationsHistoryTable(schemaPrefix, mainSearchPath);
+ })
+ .ReplaceService();
}
private string GetSearchPath(string connectionString)
diff --git a/BTCPayServer.Abstractions/Models/DatabaseOptions.cs b/BTCPayServer.Abstractions/Models/DatabaseOptions.cs
index b4a3f8801..bc2e3d885 100644
--- a/BTCPayServer.Abstractions/Models/DatabaseOptions.cs
+++ b/BTCPayServer.Abstractions/Models/DatabaseOptions.cs
@@ -2,7 +2,6 @@ namespace BTCPayServer.Abstractions.Models
{
public class DatabaseOptions
{
- public DatabaseType DatabaseType { get; set; }
public string ConnectionString { get; set; }
}
}
diff --git a/BTCPayServer.Abstractions/Models/DatabaseType.cs b/BTCPayServer.Abstractions/Models/DatabaseType.cs
deleted file mode 100644
index 09347b2e1..000000000
--- a/BTCPayServer.Abstractions/Models/DatabaseType.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace BTCPayServer.Abstractions.Models
-{
- public enum DatabaseType
- {
- Sqlite,
- Postgres,
- MySQL,
- }
-}
diff --git a/BTCPayServer.Data/ApplicationDbContext.cs b/BTCPayServer.Data/ApplicationDbContext.cs
index bc60fa9dd..2614cfc94 100644
--- a/BTCPayServer.Data/ApplicationDbContext.cs
+++ b/BTCPayServer.Data/ApplicationDbContext.cs
@@ -12,30 +12,18 @@ namespace BTCPayServer.Data
{
public ApplicationDbContext CreateDbContext(string[] args)
{
-
var builder = new DbContextOptionsBuilder();
-
- builder.UseSqlite("Data Source=temp.db");
-
- return new ApplicationDbContext(builder.Options, true);
+ // Same as launchsettings.json, it's connecting to the docker's postgres.
+ builder.UseNpgsql("User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=btcpayserver");
+ return new ApplicationDbContext(builder.Options);
}
}
-
public class ApplicationDbContext : IdentityDbContext
{
- private readonly bool _designTime;
-
- public ApplicationDbContext(DbContextOptions options, bool designTime = false)
+ public ApplicationDbContext(DbContextOptions options)
: base(options)
{
- _designTime = designTime;
}
-#nullable enable
- public async Task GetMigrationState()
- {
- return (await Settings.FromSqlRaw("SELECT \"Id\", \"Value\" FROM \"Settings\" WHERE \"Id\"='MigrationData'").AsNoTracking().FirstOrDefaultAsync())?.Value;
- }
-#nullable restore
public DbSet AddressInvoices { get; set; }
public DbSet ApiKeys { get; set; }
public DbSet Apps { get; set; }
@@ -76,13 +64,6 @@ namespace BTCPayServer.Data
public DbSet PayoutProcessors { get; set; }
public DbSet Forms { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- var isConfigured = optionsBuilder.Options.Extensions.OfType().Any();
- if (!isConfigured)
- optionsBuilder.UseSqlite("Data Source=temp.db");
- }
-
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
@@ -129,28 +110,6 @@ namespace BTCPayServer.Data
WebhookData.OnModelCreating(builder, Database);
FormData.OnModelCreating(builder, Database);
StoreRole.OnModelCreating(builder, Database);
-
-
- if (Database.IsSqlite() && !_designTime)
- {
- // SQLite does not have proper support for DateTimeOffset via Entity Framework Core, see the limitations
- // here: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations#query-limitations
- // To work around this, when the Sqlite database provider is used, all model properties of type DateTimeOffset
- // use the DateTimeOffsetToBinaryConverter
- // Based on: https://github.com/aspnet/EntityFrameworkCore/issues/10784#issuecomment-415769754
- // This only supports millisecond precision, but should be sufficient for most use cases.
- foreach (var entityType in builder.Model.GetEntityTypes())
- {
- var properties = entityType.ClrType.GetProperties().Where(p => p.PropertyType == typeof(DateTimeOffset));
- foreach (var property in properties)
- {
- builder
- .Entity(entityType.Name)
- .Property(property.Name)
- .HasConversion(new Microsoft.EntityFrameworkCore.Storage.ValueConversion.DateTimeOffsetToBinaryConverter());
- }
- }
- }
}
}
diff --git a/BTCPayServer.Data/Data/APIKeyData.cs b/BTCPayServer.Data/Data/APIKeyData.cs
index e0de051fa..48e2d6972 100644
--- a/BTCPayServer.Data/Data/APIKeyData.cs
+++ b/BTCPayServer.Data/Data/APIKeyData.cs
@@ -41,12 +41,9 @@ namespace BTCPayServer.Data
builder.Entity()
.HasIndex(o => o.StoreId);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
}
diff --git a/BTCPayServer.Data/Data/AppData.cs b/BTCPayServer.Data/Data/AppData.cs
index 784f9162c..c2de73233 100644
--- a/BTCPayServer.Data/Data/AppData.cs
+++ b/BTCPayServer.Data/Data/AppData.cs
@@ -25,12 +25,9 @@ namespace BTCPayServer.Data
builder.Entity()
.HasOne(a => a.StoreData);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Settings)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Settings)
+ .HasColumnType("JSONB");
}
// utility methods
diff --git a/BTCPayServer.Data/Data/ApplicationUser.cs b/BTCPayServer.Data/Data/ApplicationUser.cs
index 3cb2972fb..f0c59c6dd 100644
--- a/BTCPayServer.Data/Data/ApplicationUser.cs
+++ b/BTCPayServer.Data/Data/ApplicationUser.cs
@@ -35,12 +35,10 @@ namespace BTCPayServer.Data
builder.Entity()
.HasMany>(user => user.UserRoles)
.WithOne().HasForeignKey(role => role.UserId);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
}
diff --git a/BTCPayServer.Data/Data/Fido2Credential.cs b/BTCPayServer.Data/Data/Fido2Credential.cs
index 6aeb5af26..086925710 100644
--- a/BTCPayServer.Data/Data/Fido2Credential.cs
+++ b/BTCPayServer.Data/Data/Fido2Credential.cs
@@ -30,12 +30,10 @@ namespace BTCPayServer.Data
.HasOne(o => o.ApplicationUser)
.WithMany(i => i.Fido2Credentials)
.HasForeignKey(i => i.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
public ApplicationUser ApplicationUser { get; set; }
diff --git a/BTCPayServer.Data/Data/FormData.cs b/BTCPayServer.Data/Data/FormData.cs
index 7519f10bf..2c8df6c96 100644
--- a/BTCPayServer.Data/Data/FormData.cs
+++ b/BTCPayServer.Data/Data/FormData.cs
@@ -21,11 +21,8 @@ public class FormData
.WithMany(o => o.Forms).OnDelete(DeleteBehavior.Cascade);
builder.Entity().HasIndex(o => o.StoreId);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Config)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Config)
+ .HasColumnType("JSONB");
}
}
diff --git a/BTCPayServer.Data/Data/InvoiceData.cs b/BTCPayServer.Data/Data/InvoiceData.cs
index 6bdbe5028..80092d02d 100644
--- a/BTCPayServer.Data/Data/InvoiceData.cs
+++ b/BTCPayServer.Data/Data/InvoiceData.cs
@@ -44,15 +44,12 @@ namespace BTCPayServer.Data
builder.Entity().HasIndex(o => o.StoreDataId);
builder.Entity().HasIndex(o => o.OrderId);
builder.Entity().HasIndex(o => o.Created);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- builder.Entity()
- .Property(o => o.Amount)
- .HasColumnType("NUMERIC");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
+ builder.Entity()
+ .Property(o => o.Amount)
+ .HasColumnType("NUMERIC");
}
}
}
diff --git a/BTCPayServer.Data/Data/LightingAddressData.cs b/BTCPayServer.Data/Data/LightingAddressData.cs
index f5115c02d..e12753f67 100644
--- a/BTCPayServer.Data/Data/LightingAddressData.cs
+++ b/BTCPayServer.Data/Data/LightingAddressData.cs
@@ -27,12 +27,9 @@ public class LightningAddressData : IHasBlob
.IsRequired()
.OnDelete(DeleteBehavior.Cascade);
builder.Entity().HasKey(o => o.Username);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
}
diff --git a/BTCPayServer.Data/Data/NotificationData.cs b/BTCPayServer.Data/Data/NotificationData.cs
index 847ccd56f..3e099980f 100644
--- a/BTCPayServer.Data/Data/NotificationData.cs
+++ b/BTCPayServer.Data/Data/NotificationData.cs
@@ -30,12 +30,9 @@ namespace BTCPayServer.Data
.HasOne(o => o.ApplicationUser)
.WithMany(n => n.Notifications)
.HasForeignKey(k => k.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
}
}
diff --git a/BTCPayServer.Data/Data/PaymentData.cs b/BTCPayServer.Data/Data/PaymentData.cs
index 4758d9ecb..52233b417 100644
--- a/BTCPayServer.Data/Data/PaymentData.cs
+++ b/BTCPayServer.Data/Data/PaymentData.cs
@@ -41,15 +41,12 @@ namespace BTCPayServer.Data
builder.Entity()
.Property(o => o.Status)
.HasConversion();
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- builder.Entity()
- .Property(o => o.Amount)
- .HasColumnType("NUMERIC");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
+ builder.Entity()
+ .Property(o => o.Amount)
+ .HasColumnType("NUMERIC");
}
}
}
diff --git a/BTCPayServer.Data/Data/PaymentRequestData.cs b/BTCPayServer.Data/Data/PaymentRequestData.cs
index cb96ced46..4abf3846d 100644
--- a/BTCPayServer.Data/Data/PaymentRequestData.cs
+++ b/BTCPayServer.Data/Data/PaymentRequestData.cs
@@ -32,12 +32,9 @@ namespace BTCPayServer.Data
builder.Entity()
.HasIndex(o => o.Status);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
}
}
diff --git a/BTCPayServer.Data/Data/PayoutData.cs b/BTCPayServer.Data/Data/PayoutData.cs
index 6f5533cf7..c1cd5b87a 100644
--- a/BTCPayServer.Data/Data/PayoutData.cs
+++ b/BTCPayServer.Data/Data/PayoutData.cs
@@ -47,32 +47,12 @@ namespace BTCPayServer.Data
builder.Entity()
.HasIndex(x => new { DestinationId = x.Destination, x.State });
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob)
- .HasColumnType("JSONB");
- builder.Entity()
- .Property(o => o.Proof)
- .HasColumnType("JSONB");
- }
- else if (databaseFacade.IsMySql())
- {
- builder.Entity()
- .Property(o => o.Blob)
- .HasConversion(new ValueConverter
- (
- convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
- convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
- ));
- builder.Entity()
- .Property(o => o.Proof)
- .HasConversion(new ValueConverter
- (
- convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
- convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
- ));
- }
+ builder.Entity()
+ .Property(o => o.Blob)
+ .HasColumnType("JSONB");
+ builder.Entity()
+ .Property(o => o.Proof)
+ .HasColumnType("JSONB");
}
// utility methods
diff --git a/BTCPayServer.Data/Data/PayoutProcessorData.cs b/BTCPayServer.Data/Data/PayoutProcessorData.cs
index 2ac197a9f..c56e93899 100644
--- a/BTCPayServer.Data/Data/PayoutProcessorData.cs
+++ b/BTCPayServer.Data/Data/PayoutProcessorData.cs
@@ -29,12 +29,9 @@ public class PayoutProcessorData : IHasBlobUntyped
.HasOne(o => o.Store)
.WithMany(data => data.PayoutProcessors).OnDelete(DeleteBehavior.Cascade);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
public override string ToString()
diff --git a/BTCPayServer.Data/Data/PullPaymentData.cs b/BTCPayServer.Data/Data/PullPaymentData.cs
index d78355f75..66abd7702 100644
--- a/BTCPayServer.Data/Data/PullPaymentData.cs
+++ b/BTCPayServer.Data/Data/PullPaymentData.cs
@@ -38,22 +38,9 @@ namespace BTCPayServer.Data
.HasOne(o => o.StoreData)
.WithMany(o => o.PullPayments).OnDelete(DeleteBehavior.Cascade);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob)
- .HasColumnType("JSONB");
- }
- else if (databaseFacade.IsMySql())
- {
- builder.Entity()
- .Property(o => o.Blob)
- .HasConversion(new ValueConverter
- (
- convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
- convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
- ));
- }
+ builder.Entity()
+ .Property(o => o.Blob)
+ .HasColumnType("JSONB");
}
public (DateTimeOffset Start, DateTimeOffset? End)? GetPeriod(DateTimeOffset now)
diff --git a/BTCPayServer.Data/Data/SettingData.cs b/BTCPayServer.Data/Data/SettingData.cs
index fefec2f65..6d17107d7 100644
--- a/BTCPayServer.Data/Data/SettingData.cs
+++ b/BTCPayServer.Data/Data/SettingData.cs
@@ -11,12 +11,9 @@ namespace BTCPayServer.Data
public static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
{
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Value)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Value)
+ .HasColumnType("JSONB");
}
}
}
diff --git a/BTCPayServer.Data/Data/StoreData.cs b/BTCPayServer.Data/Data/StoreData.cs
index ac2b1d0cb..d42e14d6d 100644
--- a/BTCPayServer.Data/Data/StoreData.cs
+++ b/BTCPayServer.Data/Data/StoreData.cs
@@ -52,26 +52,13 @@ namespace BTCPayServer.Data
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
{
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.StoreBlob)
- .HasColumnType("JSONB");
+ builder.Entity()
+ .Property(o => o.StoreBlob)
+ .HasColumnType("JSONB");
- builder.Entity()
- .Property(o => o.DerivationStrategies)
- .HasColumnType("JSONB");
- }
- else if (databaseFacade.IsMySql())
- {
- builder.Entity()
- .Property(o => o.StoreBlob)
- .HasConversion(new ValueConverter
- (
- convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
- convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
- ));
- }
+ builder.Entity()
+ .Property(o => o.DerivationStrategies)
+ .HasColumnType("JSONB");
}
}
}
diff --git a/BTCPayServer.Data/Data/StoreRole.cs b/BTCPayServer.Data/Data/StoreRole.cs
index 78de92879..b872300eb 100644
--- a/BTCPayServer.Data/Data/StoreRole.cs
+++ b/BTCPayServer.Data/Data/StoreRole.cs
@@ -31,20 +31,5 @@ public class StoreRole
entity.HasIndex(entity => new {entity.StoreDataId, entity.Role}).IsUnique();
});
-
-
-
- if (!databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Permissions)
- .HasConversion(
- v => JsonConvert.SerializeObject(v),
- v => JsonConvert.DeserializeObject>(v)?? new List(),
- new ValueComparer>(
- (c1, c2) => c1 ==c2 || c1 != null && c2 != null && c1.SequenceEqual(c2),
- c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
- c => c.ToList()));
- }
}
}
diff --git a/BTCPayServer.Data/Data/StoreSettingData.cs b/BTCPayServer.Data/Data/StoreSettingData.cs
index aa89588d7..88319f33c 100644
--- a/BTCPayServer.Data/Data/StoreSettingData.cs
+++ b/BTCPayServer.Data/Data/StoreSettingData.cs
@@ -18,11 +18,9 @@ public class StoreSettingData
builder.Entity()
.HasOne(o => o.Store)
.WithMany(o => o.Settings).OnDelete(DeleteBehavior.Cascade);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Value)
- .HasColumnType("JSONB");
- }
+
+ builder.Entity()
+ .Property(o => o.Value)
+ .HasColumnType("JSONB");
}
}
diff --git a/BTCPayServer.Data/Data/WalletObjectData.cs b/BTCPayServer.Data/Data/WalletObjectData.cs
index 15b514dda..7d6c304a6 100644
--- a/BTCPayServer.Data/Data/WalletObjectData.cs
+++ b/BTCPayServer.Data/Data/WalletObjectData.cs
@@ -83,13 +83,9 @@ namespace BTCPayServer.Data
o.Id
});
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Data)
- .HasColumnType("JSONB");
-
- }
+ builder.Entity()
+ .Property(o => o.Data)
+ .HasColumnType("JSONB");
}
public bool Equals(WalletObjectData x, WalletObjectData y)
diff --git a/BTCPayServer.Data/Data/WalletObjectLinkData.cs b/BTCPayServer.Data/Data/WalletObjectLinkData.cs
index 9393c4589..5c4dae137 100644
--- a/BTCPayServer.Data/Data/WalletObjectLinkData.cs
+++ b/BTCPayServer.Data/Data/WalletObjectLinkData.cs
@@ -50,12 +50,9 @@ namespace BTCPayServer.Data
.HasForeignKey(o => new { o.WalletId, o.BType, o.BId })
.OnDelete(DeleteBehavior.Cascade);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Data)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Data)
+ .HasColumnType("JSONB");
}
}
}
diff --git a/BTCPayServer.Data/Data/WebhookData.cs b/BTCPayServer.Data/Data/WebhookData.cs
index c251cf4b8..c2655f3df 100644
--- a/BTCPayServer.Data/Data/WebhookData.cs
+++ b/BTCPayServer.Data/Data/WebhookData.cs
@@ -18,12 +18,9 @@ namespace BTCPayServer.Data
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
{
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob2)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Blob2)
+ .HasColumnType("JSONB");
}
}
}
diff --git a/BTCPayServer.Data/Data/WebhookDeliveryData.cs b/BTCPayServer.Data/Data/WebhookDeliveryData.cs
index 53ecbdb5b..977834f9d 100644
--- a/BTCPayServer.Data/Data/WebhookDeliveryData.cs
+++ b/BTCPayServer.Data/Data/WebhookDeliveryData.cs
@@ -27,12 +27,9 @@ namespace BTCPayServer.Data
.WithMany(a => a.Deliveries).OnDelete(DeleteBehavior.Cascade);
builder.Entity().HasIndex(o => o.WebhookId);
builder.Entity().HasIndex(o => o.Timestamp);
- if (databaseFacade.IsNpgsql())
- {
- builder.Entity()
- .Property(o => o.Blob)
- .HasColumnType("JSONB");
- }
+ builder.Entity()
+ .Property(o => o.Blob)
+ .HasColumnType("JSONB");
}
}
}
diff --git a/BTCPayServer.Data/Migrations/20170913143004_Init.cs b/BTCPayServer.Data/Migrations/20170913143004_Init.cs
index 70707fc2a..36736869c 100644
--- a/BTCPayServer.Data/Migrations/20170913143004_Init.cs
+++ b/BTCPayServer.Data/Migrations/20170913143004_Init.cs
@@ -11,12 +11,11 @@ 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, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
ConcurrencyStamp = table.Column(nullable: true),
Name = table.Column(maxLength: 256, nullable: true),
NormalizedName = table.Column(maxLength: 256, nullable: true)
@@ -30,7 +29,7 @@ namespace BTCPayServer.Migrations
name: "AspNetUsers",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
AccessFailedCount = table.Column(nullable: false),
ConcurrencyStamp = table.Column(nullable: true),
Email = table.Column(maxLength: 256, nullable: true),
@@ -55,7 +54,7 @@ namespace BTCPayServer.Migrations
name: "Stores",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
DerivationStrategy = table.Column(nullable: true),
SpeedPolicy = table.Column(nullable: false),
StoreCertificate = table.Column(nullable: true),
@@ -75,7 +74,7 @@ namespace BTCPayServer.Migrations
.Annotation("Sqlite:Autoincrement", true),
ClaimType = table.Column(nullable: true),
ClaimValue = table.Column(nullable: true),
- RoleId = table.Column(nullable: false, maxLength: maxLength)
+ RoleId = table.Column(nullable: false, maxLength: null)
},
constraints: table =>
{
@@ -96,7 +95,7 @@ namespace BTCPayServer.Migrations
.Annotation("Sqlite:Autoincrement", true),
ClaimType = table.Column(nullable: true),
ClaimValue = table.Column(nullable: true),
- UserId = table.Column(nullable: false, maxLength: maxLength)
+ UserId = table.Column(nullable: false, maxLength: null)
},
constraints: table =>
{
@@ -116,7 +115,7 @@ namespace BTCPayServer.Migrations
LoginProvider = table.Column(nullable: false, maxLength: 255),
ProviderKey = table.Column(nullable: false, maxLength: 255),
ProviderDisplayName = table.Column(nullable: true),
- UserId = table.Column(nullable: false, maxLength: maxLength)
+ UserId = table.Column(nullable: false, maxLength: null)
},
constraints: table =>
{
@@ -133,8 +132,8 @@ namespace BTCPayServer.Migrations
name: "AspNetUserRoles",
columns: table => new
{
- UserId = table.Column(nullable: false, maxLength: maxLength),
- RoleId = table.Column(nullable: false, maxLength: maxLength)
+ UserId = table.Column(nullable: false, maxLength: null),
+ RoleId = table.Column(nullable: false, maxLength: null)
},
constraints: table =>
{
@@ -157,7 +156,7 @@ namespace BTCPayServer.Migrations
name: "AspNetUserTokens",
columns: table => new
{
- UserId = table.Column(nullable: false, maxLength: maxLength),
+ UserId = table.Column(nullable: false, maxLength: null),
LoginProvider = table.Column(nullable: false, maxLength: 64),
Name = table.Column(nullable: false, maxLength: 64),
Value = table.Column(nullable: true)
@@ -177,7 +176,7 @@ namespace BTCPayServer.Migrations
name: "Invoices",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
Blob = table.Column(nullable: true),
Created = table.Column(nullable: false),
CustomerEmail = table.Column(nullable: true),
@@ -185,7 +184,7 @@ namespace BTCPayServer.Migrations
ItemCode = table.Column(nullable: true),
OrderId = table.Column(nullable: true),
Status = table.Column(nullable: true),
- StoreDataId = table.Column(nullable: true, maxLength: maxLength)
+ StoreDataId = table.Column(nullable: true, maxLength: null)
},
constraints: table =>
{
@@ -202,8 +201,8 @@ namespace BTCPayServer.Migrations
name: "UserStore",
columns: table => new
{
- ApplicationUserId = table.Column(nullable: false, maxLength: maxLength),
- StoreDataId = table.Column(nullable: false, maxLength: maxLength),
+ ApplicationUserId = table.Column(nullable: false, maxLength: null),
+ StoreDataId = table.Column(nullable: false, maxLength: null),
Role = table.Column(nullable: true)
},
constraints: table =>
@@ -227,9 +226,9 @@ namespace BTCPayServer.Migrations
name: "Payments",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
Blob = table.Column(nullable: true),
- InvoiceDataId = table.Column(nullable: true, maxLength: maxLength)
+ InvoiceDataId = table.Column(nullable: true, maxLength: null)
},
constraints: table =>
{
@@ -246,9 +245,9 @@ namespace BTCPayServer.Migrations
name: "RefundAddresses",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
Blob = table.Column(nullable: true),
- InvoiceDataId = table.Column(nullable: true, maxLength: maxLength)
+ InvoiceDataId = table.Column(nullable: true, maxLength: null)
},
constraints: table =>
{
diff --git a/BTCPayServer.Data/Migrations/20170926073744_Settings.cs b/BTCPayServer.Data/Migrations/20170926073744_Settings.cs
index 488e0d820..67ea47fda 100644
--- a/BTCPayServer.Data/Migrations/20170926073744_Settings.cs
+++ b/BTCPayServer.Data/Migrations/20170926073744_Settings.cs
@@ -10,12 +10,11 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "Settings",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
Value = table.Column(nullable: true)
},
constraints: table =>
diff --git a/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs b/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs
index 9a123c0c0..d1e7bc831 100644
--- a/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs
+++ b/BTCPayServer.Data/Migrations/20170926084408_RequiresEmailConfirmation.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "RequiresEmailConfirmation",
table: "AspNetUsers",
nullable: false,
diff --git a/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs b/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs
index 756be1e29..011ff100d 100644
--- a/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs
+++ b/BTCPayServer.Data/Migrations/20171006013443_AddressMapping.cs
@@ -10,13 +10,12 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "AddressInvoices",
columns: table => new
{
- Address = table.Column(nullable: false, maxLength: this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)512 : null),
- InvoiceDataId = table.Column(nullable: true, maxLength: maxLength)
+ Address = table.Column(nullable: false, maxLength: null),
+ InvoiceDataId = table.Column(nullable: true, maxLength: null)
},
constraints: table =>
{
diff --git a/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs b/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs
index 2bb7f08ad..1846dbdb1 100644
--- a/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs
+++ b/BTCPayServer.Data/Migrations/20171010082424_Tokens.cs
@@ -11,18 +11,17 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "PairedSINData",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
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, maxLength: maxLength),
- StoreDataId = table.Column(nullable: true, maxLength: maxLength)
+ SIN = table.Column(nullable: true, maxLength: null),
+ StoreDataId = table.Column(nullable: true, maxLength: null)
},
constraints: table =>
{
@@ -33,14 +32,14 @@ namespace BTCPayServer.Migrations
name: "PairingCodes",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
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, maxLength: maxLength),
+ StoreDataId = table.Column(nullable: true, maxLength: null),
TokenValue = table.Column(nullable: true)
},
constraints: table =>
diff --git a/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs b/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs
index 5ed483217..57bbfc964 100644
--- a/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs
+++ b/BTCPayServer.Data/Migrations/20171012020112_PendingInvoices.cs
@@ -10,22 +10,18 @@ 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(
- name: "Name",
- table: "PairingCodes");
+ 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(nullable: false, maxLength: maxLength)
+ Id = table.Column(nullable: false, maxLength: null)
},
constraints: table =>
{
diff --git a/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs b/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs
index 67e5543fe..deec42c08 100644
--- a/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs
+++ b/BTCPayServer.Data/Migrations/20171023101754_StoreBlob.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "StoreBlob",
table: "Stores",
nullable: true);
diff --git a/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs b/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs
index 9a50572f6..eb222a16d 100644
--- a/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs
+++ b/BTCPayServer.Data/Migrations/20171024163354_RenewUsedAddresses.cs
@@ -11,7 +11,6 @@ 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,8 +20,8 @@ namespace BTCPayServer.Migrations
name: "HistoricalAddressInvoices",
columns: table => new
{
- InvoiceDataId = table.Column(nullable: false, maxLength: maxLength),
- Address = table.Column(nullable: false, maxLength: this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)512 : null),
+ InvoiceDataId = table.Column(nullable: false, maxLength: null),
+ Address = table.Column(nullable: false, maxLength: null),
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 04445b8e4..c0e3f02c2 100644
--- a/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs
+++ b/BTCPayServer.Data/Migrations/20171105235734_PaymentAccounted.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "Accounted",
table: "Payments",
nullable: false,
diff --git a/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs b/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs
index ba670f25b..b07ecf638 100644
--- a/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs
+++ b/BTCPayServer.Data/Migrations/20171221054550_AltcoinSupport.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "CryptoCode",
table: "HistoricalAddressInvoices",
nullable: true);
diff --git a/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs b/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs
index 692486b10..ed760fe52 100644
--- a/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs
+++ b/BTCPayServer.Data/Migrations/20180106095215_DerivationStrategies.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "DerivationStrategies",
table: "Stores",
nullable: true);
diff --git a/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs b/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs
index 9a1819f1a..393526634 100644
--- a/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs
+++ b/BTCPayServer.Data/Migrations/20180109021122_defaultcrypto.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "DefaultCrypto",
table: "Stores",
nullable: true);
diff --git a/BTCPayServer.Data/Migrations/20180114123253_events.cs b/BTCPayServer.Data/Migrations/20180114123253_events.cs
index 9abc9d0e0..df9af20dc 100644
--- a/BTCPayServer.Data/Migrations/20180114123253_events.cs
+++ b/BTCPayServer.Data/Migrations/20180114123253_events.cs
@@ -11,13 +11,12 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "InvoiceEvents",
columns: table => new
{
- InvoiceDataId = table.Column(nullable: false, maxLength: maxLength),
- UniqueId = table.Column(nullable: false, maxLength: maxLength),
+ InvoiceDataId = table.Column(nullable: false, maxLength: null),
+ UniqueId = table.Column(nullable: false, maxLength: null),
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 07f32f64a..bd53c1072 100644
--- a/BTCPayServer.Data/Migrations/20180402095640_appdata.cs
+++ b/BTCPayServer.Data/Migrations/20180402095640_appdata.cs
@@ -11,17 +11,16 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "Apps",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
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, maxLength: maxLength)
+ StoreDataId = table.Column(nullable: true, maxLength: null)
},
constraints: table =>
{
diff --git a/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs b/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs
index 1beb80638..ce34d303f 100644
--- a/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs
+++ b/BTCPayServer.Data/Migrations/20180429083930_legacyapikey.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "ApiKeys",
columns: table => new
{
diff --git a/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs b/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs
index 39e9c9235..a30065936 100644
--- a/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs
+++ b/BTCPayServer.Data/Migrations/20180719095626_CanDeleteStores.cs
@@ -10,93 +10,89 @@ 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(
+ migrationBuilder.DropForeignKey(
+ name: "FK_AddressInvoices_Invoices_InvoiceDataId",
+ table: "AddressInvoices");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Apps_Stores_StoreDataId",
+ table: "Apps");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Invoices_Stores_StoreDataId",
+ table: "Invoices");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Payments_Invoices_InvoiceDataId",
+ table: "Payments");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_RefundAddresses_Invoices_InvoiceDataId",
+ table: "RefundAddresses");
+
+ migrationBuilder.AddForeignKey(
name: "FK_AddressInvoices_Invoices_InvoiceDataId",
- table: "AddressInvoices");
+ table: "AddressInvoices",
+ column: "InvoiceDataId",
+ principalTable: "Invoices",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
- migrationBuilder.DropForeignKey(
- name: "FK_Apps_Stores_StoreDataId",
- table: "Apps");
+ migrationBuilder.AddForeignKey(
+ name: "FK_ApiKeys_Stores_StoreId",
+ table: "ApiKeys",
+ column: "StoreId",
+ principalTable: "Stores",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
- migrationBuilder.DropForeignKey(
- name: "FK_Invoices_Stores_StoreDataId",
- table: "Invoices");
+ migrationBuilder.AddForeignKey(
+ name: "FK_Apps_Stores_StoreDataId",
+ table: "Apps",
+ column: "StoreDataId",
+ principalTable: "Stores",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
- migrationBuilder.DropForeignKey(
- name: "FK_Payments_Invoices_InvoiceDataId",
- table: "Payments");
+ migrationBuilder.AddForeignKey(
+ name: "FK_Invoices_Stores_StoreDataId",
+ table: "Invoices",
+ column: "StoreDataId",
+ principalTable: "Stores",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
- migrationBuilder.DropForeignKey(
- name: "FK_RefundAddresses_Invoices_InvoiceDataId",
- table: "RefundAddresses");
+ migrationBuilder.AddForeignKey(
+ name: "FK_PairedSINData_Stores_StoreDataId",
+ table: "PairedSINData",
+ column: "StoreDataId",
+ principalTable: "Stores",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
- migrationBuilder.AddForeignKey(
- name: "FK_AddressInvoices_Invoices_InvoiceDataId",
- table: "AddressInvoices",
- column: "InvoiceDataId",
- principalTable: "Invoices",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
+ migrationBuilder.AddForeignKey(
+ name: "FK_Payments_Invoices_InvoiceDataId",
+ table: "Payments",
+ column: "InvoiceDataId",
+ principalTable: "Invoices",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
- migrationBuilder.AddForeignKey(
- name: "FK_ApiKeys_Stores_StoreId",
- table: "ApiKeys",
- column: "StoreId",
- principalTable: "Stores",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
+ migrationBuilder.AddForeignKey(
+ name: "FK_PendingInvoices_Invoices_Id",
+ table: "PendingInvoices",
+ column: "Id",
+ principalTable: "Invoices",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
- migrationBuilder.AddForeignKey(
- name: "FK_Apps_Stores_StoreDataId",
- table: "Apps",
- column: "StoreDataId",
- principalTable: "Stores",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Invoices_Stores_StoreDataId",
- table: "Invoices",
- column: "StoreDataId",
- principalTable: "Stores",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_PairedSINData_Stores_StoreDataId",
- table: "PairedSINData",
- column: "StoreDataId",
- principalTable: "Stores",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_Payments_Invoices_InvoiceDataId",
- table: "Payments",
- column: "InvoiceDataId",
- principalTable: "Invoices",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_PendingInvoices_Invoices_Id",
- table: "PendingInvoices",
- column: "Id",
- principalTable: "Invoices",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
-
- migrationBuilder.AddForeignKey(
- name: "FK_RefundAddresses_Invoices_InvoiceDataId",
- table: "RefundAddresses",
- column: "InvoiceDataId",
- principalTable: "Invoices",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- }
+ migrationBuilder.AddForeignKey(
+ name: "FK_RefundAddresses_Invoices_InvoiceDataId",
+ table: "RefundAddresses",
+ column: "InvoiceDataId",
+ principalTable: "Invoices",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
diff --git a/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs b/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs
index 3902624ab..35819b286 100644
--- a/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs
+++ b/BTCPayServer.Data/Migrations/20190121133309_AddPaymentRequests.cs
@@ -10,13 +10,12 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "PaymentRequests",
columns: table => new
{
- Id = table.Column(nullable: false, maxLength: maxLength),
- StoreDataId = table.Column(nullable: true, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
+ StoreDataId = table.Column(nullable: true, maxLength: null),
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 ecdccd0b9..47193479b 100644
--- a/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs
+++ b/BTCPayServer.Data/Migrations/20190219032533_AppsTagging.cs
@@ -10,8 +10,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.AddColumn(
+ migrationBuilder.AddColumn(
name: "TagAllInvoices",
table: "Apps",
nullable: false,
diff --git a/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs b/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs
index dfcfe169a..92fe48d2b 100644
--- a/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs
+++ b/BTCPayServer.Data/Migrations/20190225091644_AddOpenIddict.cs
@@ -11,8 +11,7 @@ namespace BTCPayServer.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
- migrationBuilder.CreateTable(
+ migrationBuilder.CreateTable(
name: "OpenIddictApplications",
columns: table => new
{
@@ -21,13 +20,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, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
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, maxLength: maxLength)
+ ApplicationUserId = table.Column(nullable: true, maxLength: null)
},
constraints: table =>
{
@@ -47,7 +46,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, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
Name = table.Column(maxLength: 200, nullable: false),
Properties = table.Column(nullable: true),
Resources = table.Column(nullable: true)
@@ -61,9 +60,9 @@ namespace BTCPayServer.Migrations
name: "OpenIddictAuthorizations",
columns: table => new
{
- ApplicationId = table.Column(nullable: true, maxLength: maxLength),
+ ApplicationId = table.Column(nullable: true, maxLength: null),
ConcurrencyToken = table.Column(maxLength: 50, nullable: true),
- Id = table.Column(nullable: false, maxLength: maxLength),
+ Id = table.Column(nullable: false, maxLength: null),
Properties = table.Column(nullable: true),
Scopes = table.Column