mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-10 09:19:24 +01:00
Remove MySQL and Sqlite deps (#5910)
This commit is contained in:
parent
9699b3837b
commit
f1a04a3bd0
86 changed files with 818 additions and 1729 deletions
|
@ -33,9 +33,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="HtmlSanitizer" Version="8.0.838" />
|
<PackageReference Include="HtmlSanitizer" Version="8.0.838" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
|
|
||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
|
||||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BTCPayServer.Client\BTCPayServer.Client.csproj" />
|
<ProjectReference Include="..\BTCPayServer.Client\BTCPayServer.Client.csproj" />
|
||||||
|
|
|
@ -13,12 +13,12 @@ namespace BTCPayServer.Abstractions.Contracts
|
||||||
public abstract class BaseDbContextFactory<T> where T : DbContext
|
public abstract class BaseDbContextFactory<T> where T : DbContext
|
||||||
{
|
{
|
||||||
private readonly IOptions<DatabaseOptions> _options;
|
private readonly IOptions<DatabaseOptions> _options;
|
||||||
private readonly string _schemaPrefix;
|
private readonly string _migrationTableName;
|
||||||
|
|
||||||
public BaseDbContextFactory(IOptions<DatabaseOptions> options, string schemaPrefix)
|
public BaseDbContextFactory(IOptions<DatabaseOptions> options, string migrationTableName)
|
||||||
{
|
{
|
||||||
_options = options;
|
_options = options;
|
||||||
_schemaPrefix = schemaPrefix;
|
_migrationTableName = migrationTableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract T CreateContext();
|
public abstract T CreateContext();
|
||||||
|
@ -68,43 +68,16 @@ namespace BTCPayServer.Abstractions.Contracts
|
||||||
|
|
||||||
public void ConfigureBuilder(DbContextOptionsBuilder builder)
|
public void ConfigureBuilder(DbContextOptionsBuilder builder)
|
||||||
{
|
{
|
||||||
switch (_options.Value.DatabaseType)
|
|
||||||
{
|
|
||||||
case DatabaseType.Sqlite:
|
|
||||||
builder.UseSqlite(_options.Value.ConnectionString, o =>
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(_schemaPrefix))
|
|
||||||
{
|
|
||||||
o.MigrationsHistoryTable(_schemaPrefix);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case DatabaseType.Postgres:
|
|
||||||
builder
|
builder
|
||||||
.UseNpgsql(_options.Value.ConnectionString, o =>
|
.UseNpgsql(_options.Value.ConnectionString, o =>
|
||||||
{
|
{
|
||||||
o.EnableRetryOnFailure(10);
|
o.EnableRetryOnFailure(10);
|
||||||
o.SetPostgresVersion(12, 0);
|
o.SetPostgresVersion(12, 0);
|
||||||
var mainSearchPath = GetSearchPath(_options.Value.ConnectionString);
|
var mainSearchPath = GetSearchPath(_options.Value.ConnectionString);
|
||||||
var schemaPrefix = string.IsNullOrEmpty(_schemaPrefix) ? "__EFMigrationsHistory" : _schemaPrefix;
|
var schemaPrefix = string.IsNullOrEmpty(_migrationTableName) ? "__EFMigrationsHistory" : _migrationTableName;
|
||||||
o.MigrationsHistoryTable(schemaPrefix, mainSearchPath);
|
o.MigrationsHistoryTable(schemaPrefix, mainSearchPath);
|
||||||
})
|
})
|
||||||
.ReplaceService<IMigrationsSqlGenerator, CustomNpgsqlMigrationsSqlGenerator>();
|
.ReplaceService<IMigrationsSqlGenerator, CustomNpgsqlMigrationsSqlGenerator>();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetSearchPath(string connectionString)
|
private string GetSearchPath(string connectionString)
|
||||||
|
|
|
@ -2,7 +2,6 @@ namespace BTCPayServer.Abstractions.Models
|
||||||
{
|
{
|
||||||
public class DatabaseOptions
|
public class DatabaseOptions
|
||||||
{
|
{
|
||||||
public DatabaseType DatabaseType { get; set; }
|
|
||||||
public string ConnectionString { get; set; }
|
public string ConnectionString { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
namespace BTCPayServer.Abstractions.Models
|
|
||||||
{
|
|
||||||
public enum DatabaseType
|
|
||||||
{
|
|
||||||
Sqlite,
|
|
||||||
Postgres,
|
|
||||||
MySQL,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,30 +12,18 @@ namespace BTCPayServer.Data
|
||||||
{
|
{
|
||||||
public ApplicationDbContext CreateDbContext(string[] args)
|
public ApplicationDbContext CreateDbContext(string[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
|
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
|
||||||
|
// Same as launchsettings.json, it's connecting to the docker's postgres.
|
||||||
builder.UseSqlite("Data Source=temp.db");
|
builder.UseNpgsql("User ID=postgres;Include Error Detail=true;Host=127.0.0.1;Port=39372;Database=btcpayserver");
|
||||||
|
return new ApplicationDbContext(builder.Options);
|
||||||
return new ApplicationDbContext(builder.Options, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
||||||
{
|
{
|
||||||
private readonly bool _designTime;
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||||
|
|
||||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options, bool designTime = false)
|
|
||||||
: base(options)
|
: base(options)
|
||||||
{
|
{
|
||||||
_designTime = designTime;
|
|
||||||
}
|
}
|
||||||
#nullable enable
|
|
||||||
public async Task<string?> GetMigrationState()
|
|
||||||
{
|
|
||||||
return (await Settings.FromSqlRaw("SELECT \"Id\", \"Value\" FROM \"Settings\" WHERE \"Id\"='MigrationData'").AsNoTracking().FirstOrDefaultAsync())?.Value;
|
|
||||||
}
|
|
||||||
#nullable restore
|
|
||||||
public DbSet<AddressInvoiceData> AddressInvoices { get; set; }
|
public DbSet<AddressInvoiceData> AddressInvoices { get; set; }
|
||||||
public DbSet<APIKeyData> ApiKeys { get; set; }
|
public DbSet<APIKeyData> ApiKeys { get; set; }
|
||||||
public DbSet<AppData> Apps { get; set; }
|
public DbSet<AppData> Apps { get; set; }
|
||||||
|
@ -76,13 +64,6 @@ namespace BTCPayServer.Data
|
||||||
public DbSet<PayoutProcessorData> PayoutProcessors { get; set; }
|
public DbSet<PayoutProcessorData> PayoutProcessors { get; set; }
|
||||||
public DbSet<FormData> Forms { get; set; }
|
public DbSet<FormData> Forms { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
var isConfigured = optionsBuilder.Options.Extensions.OfType<RelationalOptionsExtension>().Any();
|
|
||||||
if (!isConfigured)
|
|
||||||
optionsBuilder.UseSqlite("Data Source=temp.db");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(builder);
|
base.OnModelCreating(builder);
|
||||||
|
@ -129,28 +110,6 @@ namespace BTCPayServer.Data
|
||||||
WebhookData.OnModelCreating(builder, Database);
|
WebhookData.OnModelCreating(builder, Database);
|
||||||
FormData.OnModelCreating(builder, Database);
|
FormData.OnModelCreating(builder, Database);
|
||||||
StoreRole.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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,11 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<APIKeyData>()
|
builder.Entity<APIKeyData>()
|
||||||
.HasIndex(o => o.StoreId);
|
.HasIndex(o => o.StoreId);
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<APIKeyData>()
|
builder.Entity<APIKeyData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class APIKeyBlob
|
public class APIKeyBlob
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,13 +25,10 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<AppData>()
|
builder.Entity<AppData>()
|
||||||
.HasOne(a => a.StoreData);
|
.HasOne(a => a.StoreData);
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<AppData>()
|
builder.Entity<AppData>()
|
||||||
.Property(o => o.Settings)
|
.Property(o => o.Settings)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// utility methods
|
// utility methods
|
||||||
public T GetSettings<T>() where T : class, new()
|
public T GetSettings<T>() where T : class, new()
|
||||||
|
|
|
@ -35,14 +35,12 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<ApplicationUser>()
|
builder.Entity<ApplicationUser>()
|
||||||
.HasMany<IdentityUserRole<string>>(user => user.UserRoles)
|
.HasMany<IdentityUserRole<string>>(user => user.UserRoles)
|
||||||
.WithOne().HasForeignKey(role => role.UserId);
|
.WithOne().HasForeignKey(role => role.UserId);
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<ApplicationUser>()
|
builder.Entity<ApplicationUser>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class UserBlob
|
public class UserBlob
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,13 +30,11 @@ namespace BTCPayServer.Data
|
||||||
.HasOne(o => o.ApplicationUser)
|
.HasOne(o => o.ApplicationUser)
|
||||||
.WithMany(i => i.Fido2Credentials)
|
.WithMany(i => i.Fido2Credentials)
|
||||||
.HasForeignKey(i => i.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
|
.HasForeignKey(i => i.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<Fido2Credential>()
|
builder.Entity<Fido2Credential>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationUser ApplicationUser { get; set; }
|
public ApplicationUser ApplicationUser { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,8 @@ public class FormData
|
||||||
.WithMany(o => o.Forms).OnDelete(DeleteBehavior.Cascade);
|
.WithMany(o => o.Forms).OnDelete(DeleteBehavior.Cascade);
|
||||||
builder.Entity<FormData>().HasIndex(o => o.StoreId);
|
builder.Entity<FormData>().HasIndex(o => o.StoreId);
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<FormData>()
|
builder.Entity<FormData>()
|
||||||
.Property(o => o.Config)
|
.Property(o => o.Config)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -44,8 +44,6 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<InvoiceData>().HasIndex(o => o.StoreDataId);
|
builder.Entity<InvoiceData>().HasIndex(o => o.StoreDataId);
|
||||||
builder.Entity<InvoiceData>().HasIndex(o => o.OrderId);
|
builder.Entity<InvoiceData>().HasIndex(o => o.OrderId);
|
||||||
builder.Entity<InvoiceData>().HasIndex(o => o.Created);
|
builder.Entity<InvoiceData>().HasIndex(o => o.Created);
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<InvoiceData>()
|
builder.Entity<InvoiceData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
|
@ -55,4 +53,3 @@ namespace BTCPayServer.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -27,14 +27,11 @@ public class LightningAddressData : IHasBlob<LightningAddressDataBlob>
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
builder.Entity<LightningAddressData>().HasKey(o => o.Username);
|
builder.Entity<LightningAddressData>().HasKey(o => o.Username);
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<LightningAddressData>()
|
builder.Entity<LightningAddressData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class LightningAddressDataBlob
|
public class LightningAddressDataBlob
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,12 +30,9 @@ namespace BTCPayServer.Data
|
||||||
.HasOne(o => o.ApplicationUser)
|
.HasOne(o => o.ApplicationUser)
|
||||||
.WithMany(n => n.Notifications)
|
.WithMany(n => n.Notifications)
|
||||||
.HasForeignKey(k => k.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
|
.HasForeignKey(k => k.ApplicationUserId).OnDelete(DeleteBehavior.Cascade);
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<NotificationData>()
|
builder.Entity<NotificationData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -41,8 +41,6 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<PaymentData>()
|
builder.Entity<PaymentData>()
|
||||||
.Property(o => o.Status)
|
.Property(o => o.Status)
|
||||||
.HasConversion<string>();
|
.HasConversion<string>();
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<PaymentData>()
|
builder.Entity<PaymentData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
|
@ -52,4 +50,3 @@ namespace BTCPayServer.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -32,12 +32,9 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<PaymentRequestData>()
|
builder.Entity<PaymentRequestData>()
|
||||||
.HasIndex(o => o.Status);
|
.HasIndex(o => o.Status);
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<PaymentRequestData>()
|
builder.Entity<PaymentRequestData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -47,8 +47,6 @@ namespace BTCPayServer.Data
|
||||||
builder.Entity<PayoutData>()
|
builder.Entity<PayoutData>()
|
||||||
.HasIndex(x => new { DestinationId = x.Destination, x.State });
|
.HasIndex(x => new { DestinationId = x.Destination, x.State });
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<PayoutData>()
|
builder.Entity<PayoutData>()
|
||||||
.Property(o => o.Blob)
|
.Property(o => o.Blob)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
|
@ -56,24 +54,6 @@ namespace BTCPayServer.Data
|
||||||
.Property(o => o.Proof)
|
.Property(o => o.Proof)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
else if (databaseFacade.IsMySql())
|
|
||||||
{
|
|
||||||
builder.Entity<PayoutData>()
|
|
||||||
.Property(o => o.Blob)
|
|
||||||
.HasConversion(new ValueConverter<string, byte[]>
|
|
||||||
(
|
|
||||||
convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
|
|
||||||
convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
|
|
||||||
));
|
|
||||||
builder.Entity<PayoutData>()
|
|
||||||
.Property(o => o.Proof)
|
|
||||||
.HasConversion(new ValueConverter<string, byte[]>
|
|
||||||
(
|
|
||||||
convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
|
|
||||||
convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// utility methods
|
// utility methods
|
||||||
public bool IsInPeriod(PullPaymentData pp, DateTimeOffset now)
|
public bool IsInPeriod(PullPaymentData pp, DateTimeOffset now)
|
||||||
|
|
|
@ -29,13 +29,10 @@ public class PayoutProcessorData : IHasBlobUntyped
|
||||||
.HasOne(o => o.Store)
|
.HasOne(o => o.Store)
|
||||||
.WithMany(data => data.PayoutProcessors).OnDelete(DeleteBehavior.Cascade);
|
.WithMany(data => data.PayoutProcessors).OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<PayoutProcessorData>()
|
builder.Entity<PayoutProcessorData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,23 +38,10 @@ namespace BTCPayServer.Data
|
||||||
.HasOne(o => o.StoreData)
|
.HasOne(o => o.StoreData)
|
||||||
.WithMany(o => o.PullPayments).OnDelete(DeleteBehavior.Cascade);
|
.WithMany(o => o.PullPayments).OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<PullPaymentData>()
|
builder.Entity<PullPaymentData>()
|
||||||
.Property(o => o.Blob)
|
.Property(o => o.Blob)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
else if (databaseFacade.IsMySql())
|
|
||||||
{
|
|
||||||
builder.Entity<PullPaymentData>()
|
|
||||||
.Property(o => o.Blob)
|
|
||||||
.HasConversion(new ValueConverter<string, byte[]>
|
|
||||||
(
|
|
||||||
convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
|
|
||||||
convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public (DateTimeOffset Start, DateTimeOffset? End)? GetPeriod(DateTimeOffset now)
|
public (DateTimeOffset Start, DateTimeOffset? End)? GetPeriod(DateTimeOffset now)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,8 +10,6 @@ namespace BTCPayServer.Data
|
||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
|
|
||||||
public static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
public static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
||||||
{
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
{
|
||||||
builder.Entity<SettingData>()
|
builder.Entity<SettingData>()
|
||||||
.Property(o => o.Value)
|
.Property(o => o.Value)
|
||||||
|
@ -19,4 +17,3 @@ namespace BTCPayServer.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -51,8 +51,6 @@ namespace BTCPayServer.Data
|
||||||
public bool Archived { get; set; }
|
public bool Archived { get; set; }
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
||||||
{
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
{
|
||||||
builder.Entity<StoreData>()
|
builder.Entity<StoreData>()
|
||||||
.Property(o => o.StoreBlob)
|
.Property(o => o.StoreBlob)
|
||||||
|
@ -62,16 +60,5 @@ namespace BTCPayServer.Data
|
||||||
.Property(o => o.DerivationStrategies)
|
.Property(o => o.DerivationStrategies)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
else if (databaseFacade.IsMySql())
|
|
||||||
{
|
|
||||||
builder.Entity<StoreData>()
|
|
||||||
.Property(o => o.StoreBlob)
|
|
||||||
.HasConversion(new ValueConverter<string, byte[]>
|
|
||||||
(
|
|
||||||
convertToProviderExpression: (str) => Encoding.UTF8.GetBytes(str),
|
|
||||||
convertFromProviderExpression: (bytes) => Encoding.UTF8.GetString(bytes)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,20 +31,5 @@ public class StoreRole
|
||||||
|
|
||||||
entity.HasIndex(entity => new {entity.StoreDataId, entity.Role}).IsUnique();
|
entity.HasIndex(entity => new {entity.StoreDataId, entity.Role}).IsUnique();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<StoreRole>()
|
|
||||||
.Property(o => o.Permissions)
|
|
||||||
.HasConversion(
|
|
||||||
v => JsonConvert.SerializeObject(v),
|
|
||||||
v => JsonConvert.DeserializeObject<List<string>>(v)?? new List<string>(),
|
|
||||||
new ValueComparer<List<string>>(
|
|
||||||
(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()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,9 @@ public class StoreSettingData
|
||||||
builder.Entity<StoreSettingData>()
|
builder.Entity<StoreSettingData>()
|
||||||
.HasOne(o => o.Store)
|
.HasOne(o => o.Store)
|
||||||
.WithMany(o => o.Settings).OnDelete(DeleteBehavior.Cascade);
|
.WithMany(o => o.Settings).OnDelete(DeleteBehavior.Cascade);
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<StoreSettingData>()
|
builder.Entity<StoreSettingData>()
|
||||||
.Property(o => o.Value)
|
.Property(o => o.Value)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -83,13 +83,9 @@ namespace BTCPayServer.Data
|
||||||
o.Id
|
o.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<WalletObjectData>()
|
builder.Entity<WalletObjectData>()
|
||||||
.Property(o => o.Data)
|
.Property(o => o.Data)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(WalletObjectData x, WalletObjectData y)
|
public bool Equals(WalletObjectData x, WalletObjectData y)
|
||||||
|
|
|
@ -50,12 +50,9 @@ namespace BTCPayServer.Data
|
||||||
.HasForeignKey(o => new { o.WalletId, o.BType, o.BId })
|
.HasForeignKey(o => new { o.WalletId, o.BType, o.BId })
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<WalletObjectLinkData>()
|
builder.Entity<WalletObjectLinkData>()
|
||||||
.Property(o => o.Data)
|
.Property(o => o.Data)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ namespace BTCPayServer.Data
|
||||||
public List<WebhookDeliveryData> Deliveries { get; set; }
|
public List<WebhookDeliveryData> Deliveries { get; set; }
|
||||||
|
|
||||||
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
internal static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
||||||
{
|
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
{
|
||||||
builder.Entity<WebhookData>()
|
builder.Entity<WebhookData>()
|
||||||
.Property(o => o.Blob2)
|
.Property(o => o.Blob2)
|
||||||
|
@ -26,4 +24,3 @@ namespace BTCPayServer.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -27,12 +27,9 @@ namespace BTCPayServer.Data
|
||||||
.WithMany(a => a.Deliveries).OnDelete(DeleteBehavior.Cascade);
|
.WithMany(a => a.Deliveries).OnDelete(DeleteBehavior.Cascade);
|
||||||
builder.Entity<WebhookDeliveryData>().HasIndex(o => o.WebhookId);
|
builder.Entity<WebhookDeliveryData>().HasIndex(o => o.WebhookId);
|
||||||
builder.Entity<WebhookDeliveryData>().HasIndex(o => o.Timestamp);
|
builder.Entity<WebhookDeliveryData>().HasIndex(o => o.Timestamp);
|
||||||
if (databaseFacade.IsNpgsql())
|
|
||||||
{
|
|
||||||
builder.Entity<WebhookDeliveryData>()
|
builder.Entity<WebhookDeliveryData>()
|
||||||
.Property(o => o.Blob)
|
.Property(o => o.Blob)
|
||||||
.HasColumnType("JSONB");
|
.HasColumnType("JSONB");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -11,12 +11,11 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "AspNetRoles",
|
name: "AspNetRoles",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
ConcurrencyStamp = table.Column<string>(nullable: true),
|
ConcurrencyStamp = table.Column<string>(nullable: true),
|
||||||
Name = table.Column<string>(maxLength: 256, nullable: true),
|
Name = table.Column<string>(maxLength: 256, nullable: true),
|
||||||
NormalizedName = table.Column<string>(maxLength: 256, nullable: true)
|
NormalizedName = table.Column<string>(maxLength: 256, nullable: true)
|
||||||
|
@ -30,7 +29,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "AspNetUsers",
|
name: "AspNetUsers",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
AccessFailedCount = table.Column<int>(nullable: false),
|
AccessFailedCount = table.Column<int>(nullable: false),
|
||||||
ConcurrencyStamp = table.Column<string>(nullable: true),
|
ConcurrencyStamp = table.Column<string>(nullable: true),
|
||||||
Email = table.Column<string>(maxLength: 256, nullable: true),
|
Email = table.Column<string>(maxLength: 256, nullable: true),
|
||||||
|
@ -55,7 +54,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "Stores",
|
name: "Stores",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
DerivationStrategy = table.Column<string>(nullable: true),
|
DerivationStrategy = table.Column<string>(nullable: true),
|
||||||
SpeedPolicy = table.Column<int>(nullable: false),
|
SpeedPolicy = table.Column<int>(nullable: false),
|
||||||
StoreCertificate = table.Column<byte[]>(nullable: true),
|
StoreCertificate = table.Column<byte[]>(nullable: true),
|
||||||
|
@ -75,7 +74,7 @@ namespace BTCPayServer.Migrations
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
ClaimType = table.Column<string>(nullable: true),
|
ClaimType = table.Column<string>(nullable: true),
|
||||||
ClaimValue = table.Column<string>(nullable: true),
|
ClaimValue = table.Column<string>(nullable: true),
|
||||||
RoleId = table.Column<string>(nullable: false, maxLength: maxLength)
|
RoleId = table.Column<string>(nullable: false, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -96,7 +95,7 @@ namespace BTCPayServer.Migrations
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
ClaimType = table.Column<string>(nullable: true),
|
ClaimType = table.Column<string>(nullable: true),
|
||||||
ClaimValue = table.Column<string>(nullable: true),
|
ClaimValue = table.Column<string>(nullable: true),
|
||||||
UserId = table.Column<string>(nullable: false, maxLength: maxLength)
|
UserId = table.Column<string>(nullable: false, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -116,7 +115,7 @@ namespace BTCPayServer.Migrations
|
||||||
LoginProvider = table.Column<string>(nullable: false, maxLength: 255),
|
LoginProvider = table.Column<string>(nullable: false, maxLength: 255),
|
||||||
ProviderKey = table.Column<string>(nullable: false, maxLength: 255),
|
ProviderKey = table.Column<string>(nullable: false, maxLength: 255),
|
||||||
ProviderDisplayName = table.Column<string>(nullable: true),
|
ProviderDisplayName = table.Column<string>(nullable: true),
|
||||||
UserId = table.Column<string>(nullable: false, maxLength: maxLength)
|
UserId = table.Column<string>(nullable: false, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -133,8 +132,8 @@ namespace BTCPayServer.Migrations
|
||||||
name: "AspNetUserRoles",
|
name: "AspNetUserRoles",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
UserId = table.Column<string>(nullable: false, maxLength: maxLength),
|
UserId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
RoleId = table.Column<string>(nullable: false, maxLength: maxLength)
|
RoleId = table.Column<string>(nullable: false, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -157,7 +156,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "AspNetUserTokens",
|
name: "AspNetUserTokens",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
UserId = table.Column<string>(nullable: false, maxLength: maxLength),
|
UserId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
LoginProvider = table.Column<string>(nullable: false, maxLength: 64),
|
LoginProvider = table.Column<string>(nullable: false, maxLength: 64),
|
||||||
Name = table.Column<string>(nullable: false, maxLength: 64),
|
Name = table.Column<string>(nullable: false, maxLength: 64),
|
||||||
Value = table.Column<string>(nullable: true)
|
Value = table.Column<string>(nullable: true)
|
||||||
|
@ -177,7 +176,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "Invoices",
|
name: "Invoices",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Blob = table.Column<byte[]>(nullable: true),
|
Blob = table.Column<byte[]>(nullable: true),
|
||||||
Created = table.Column<DateTimeOffset>(nullable: false),
|
Created = table.Column<DateTimeOffset>(nullable: false),
|
||||||
CustomerEmail = table.Column<string>(nullable: true),
|
CustomerEmail = table.Column<string>(nullable: true),
|
||||||
|
@ -185,7 +184,7 @@ namespace BTCPayServer.Migrations
|
||||||
ItemCode = table.Column<string>(nullable: true),
|
ItemCode = table.Column<string>(nullable: true),
|
||||||
OrderId = table.Column<string>(nullable: true),
|
OrderId = table.Column<string>(nullable: true),
|
||||||
Status = table.Column<string>(nullable: true),
|
Status = table.Column<string>(nullable: true),
|
||||||
StoreDataId = table.Column<string>(nullable: true, maxLength: maxLength)
|
StoreDataId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -202,8 +201,8 @@ namespace BTCPayServer.Migrations
|
||||||
name: "UserStore",
|
name: "UserStore",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
ApplicationUserId = table.Column<string>(nullable: false, maxLength: maxLength),
|
ApplicationUserId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
StoreDataId = table.Column<string>(nullable: false, maxLength: maxLength),
|
StoreDataId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Role = table.Column<string>(nullable: true)
|
Role = table.Column<string>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
|
@ -227,9 +226,9 @@ namespace BTCPayServer.Migrations
|
||||||
name: "Payments",
|
name: "Payments",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Blob = table.Column<byte[]>(nullable: true),
|
Blob = table.Column<byte[]>(nullable: true),
|
||||||
InvoiceDataId = table.Column<string>(nullable: true, maxLength: maxLength)
|
InvoiceDataId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -246,9 +245,9 @@ namespace BTCPayServer.Migrations
|
||||||
name: "RefundAddresses",
|
name: "RefundAddresses",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Blob = table.Column<byte[]>(nullable: true),
|
Blob = table.Column<byte[]>(nullable: true),
|
||||||
InvoiceDataId = table.Column<string>(nullable: true, maxLength: maxLength)
|
InvoiceDataId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,12 +10,11 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Settings",
|
name: "Settings",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Value = table.Column<string>(nullable: true)
|
Value = table.Column<string>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
migrationBuilder.AddColumn<bool>(
|
||||||
name: "RequiresEmailConfirmation",
|
name: "RequiresEmailConfirmation",
|
||||||
table: "AspNetUsers",
|
table: "AspNetUsers",
|
||||||
|
|
|
@ -10,13 +10,12 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "AddressInvoices",
|
name: "AddressInvoices",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Address = table.Column<string>(nullable: false, maxLength: this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)512 : null),
|
Address = table.Column<string>(nullable: false, maxLength: null),
|
||||||
InvoiceDataId = table.Column<string>(nullable: true, maxLength: maxLength)
|
InvoiceDataId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,18 +11,17 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "PairedSINData",
|
name: "PairedSINData",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Facade = table.Column<string>(nullable: true),
|
Facade = table.Column<string>(nullable: true),
|
||||||
Label = table.Column<string>(nullable: true),
|
Label = table.Column<string>(nullable: true),
|
||||||
Name = table.Column<string>(nullable: true),
|
Name = table.Column<string>(nullable: true),
|
||||||
PairingTime = table.Column<DateTimeOffset>(nullable: false),
|
PairingTime = table.Column<DateTimeOffset>(nullable: false),
|
||||||
SIN = table.Column<string>(nullable: true, maxLength: maxLength),
|
SIN = table.Column<string>(nullable: true, maxLength: null),
|
||||||
StoreDataId = table.Column<string>(nullable: true, maxLength: maxLength)
|
StoreDataId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -33,14 +32,14 @@ namespace BTCPayServer.Migrations
|
||||||
name: "PairingCodes",
|
name: "PairingCodes",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
DateCreated = table.Column<DateTime>(nullable: false),
|
DateCreated = table.Column<DateTime>(nullable: false),
|
||||||
Expiration = table.Column<DateTimeOffset>(nullable: false),
|
Expiration = table.Column<DateTimeOffset>(nullable: false),
|
||||||
Facade = table.Column<string>(nullable: true),
|
Facade = table.Column<string>(nullable: true),
|
||||||
Label = table.Column<string>(nullable: true),
|
Label = table.Column<string>(nullable: true),
|
||||||
Name = table.Column<string>(nullable: true),
|
Name = table.Column<string>(nullable: true),
|
||||||
SIN = table.Column<string>(nullable: true),
|
SIN = table.Column<string>(nullable: true),
|
||||||
StoreDataId = table.Column<string>(nullable: true, maxLength: maxLength),
|
StoreDataId = table.Column<string>(nullable: true, maxLength: null),
|
||||||
TokenValue = table.Column<string>(nullable: true)
|
TokenValue = table.Column<string>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
|
|
|
@ -9,9 +9,6 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class PendingInvoices : Migration
|
public partial class PendingInvoices : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Name",
|
name: "Name",
|
||||||
|
@ -20,12 +17,11 @@ namespace BTCPayServer.Migrations
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Name",
|
name: "Name",
|
||||||
table: "PairedSINData");
|
table: "PairedSINData");
|
||||||
}
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "PendingInvoices",
|
name: "PendingInvoices",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength)
|
Id = table.Column<string>(nullable: false, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<byte[]>(
|
migrationBuilder.AddColumn<byte[]>(
|
||||||
name: "StoreBlob",
|
name: "StoreBlob",
|
||||||
table: "Stores",
|
table: "Stores",
|
||||||
|
|
|
@ -11,7 +11,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||||
name: "CreatedTime",
|
name: "CreatedTime",
|
||||||
table: "AddressInvoices",
|
table: "AddressInvoices",
|
||||||
|
@ -21,8 +20,8 @@ namespace BTCPayServer.Migrations
|
||||||
name: "HistoricalAddressInvoices",
|
name: "HistoricalAddressInvoices",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
InvoiceDataId = table.Column<string>(nullable: false, maxLength: maxLength),
|
InvoiceDataId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Address = table.Column<string>(nullable: false, maxLength: this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)512 : null),
|
Address = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Assigned = table.Column<DateTimeOffset>(nullable: false),
|
Assigned = table.Column<DateTimeOffset>(nullable: false),
|
||||||
UnAssigned = table.Column<DateTimeOffset>(nullable: true)
|
UnAssigned = table.Column<DateTimeOffset>(nullable: true)
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
migrationBuilder.AddColumn<bool>(
|
||||||
name: "Accounted",
|
name: "Accounted",
|
||||||
table: "Payments",
|
table: "Payments",
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "CryptoCode",
|
name: "CryptoCode",
|
||||||
table: "HistoricalAddressInvoices",
|
table: "HistoricalAddressInvoices",
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "DerivationStrategies",
|
name: "DerivationStrategies",
|
||||||
table: "Stores",
|
table: "Stores",
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "DefaultCrypto",
|
name: "DefaultCrypto",
|
||||||
table: "Stores",
|
table: "Stores",
|
||||||
|
|
|
@ -11,13 +11,12 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "InvoiceEvents",
|
name: "InvoiceEvents",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
InvoiceDataId = table.Column<string>(nullable: false, maxLength: maxLength),
|
InvoiceDataId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
UniqueId = table.Column<string>(nullable: false, maxLength: maxLength),
|
UniqueId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Message = table.Column<string>(nullable: true),
|
Message = table.Column<string>(nullable: true),
|
||||||
Timestamp = table.Column<DateTimeOffset>(nullable: false)
|
Timestamp = table.Column<DateTimeOffset>(nullable: false)
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,17 +11,16 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Apps",
|
name: "Apps",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
AppType = table.Column<string>(nullable: true),
|
AppType = table.Column<string>(nullable: true),
|
||||||
Created = table.Column<DateTimeOffset>(nullable: false),
|
Created = table.Column<DateTimeOffset>(nullable: false),
|
||||||
Name = table.Column<string>(nullable: true),
|
Name = table.Column<string>(nullable: true),
|
||||||
Settings = table.Column<string>(nullable: true),
|
Settings = table.Column<string>(nullable: true),
|
||||||
StoreDataId = table.Column<string>(nullable: true, maxLength: maxLength)
|
StoreDataId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ApiKeys",
|
name: "ApiKeys",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
|
|
|
@ -9,9 +9,6 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class CanDeleteStores : Migration
|
public partial class CanDeleteStores : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
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",
|
name: "FK_AddressInvoices_Invoices_InvoiceDataId",
|
||||||
|
@ -97,7 +94,6 @@ namespace BTCPayServer.Migrations
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,13 +10,12 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "PaymentRequests",
|
name: "PaymentRequests",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
StoreDataId = table.Column<string>(nullable: true, maxLength: maxLength),
|
StoreDataId = table.Column<string>(nullable: true, maxLength: null),
|
||||||
Status = table.Column<int>(nullable: false),
|
Status = table.Column<int>(nullable: false),
|
||||||
Blob = table.Column<byte[]>(nullable: true)
|
Blob = table.Column<byte[]>(nullable: true)
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<bool>(
|
migrationBuilder.AddColumn<bool>(
|
||||||
name: "TagAllInvoices",
|
name: "TagAllInvoices",
|
||||||
table: "Apps",
|
table: "Apps",
|
||||||
|
|
|
@ -11,7 +11,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "OpenIddictApplications",
|
name: "OpenIddictApplications",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
|
@ -21,13 +20,13 @@ namespace BTCPayServer.Migrations
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
||||||
ConsentType = table.Column<string>(nullable: true),
|
ConsentType = table.Column<string>(nullable: true),
|
||||||
DisplayName = table.Column<string>(nullable: true),
|
DisplayName = table.Column<string>(nullable: true),
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Permissions = table.Column<string>(nullable: true),
|
Permissions = table.Column<string>(nullable: true),
|
||||||
PostLogoutRedirectUris = table.Column<string>(nullable: true),
|
PostLogoutRedirectUris = table.Column<string>(nullable: true),
|
||||||
Properties = table.Column<string>(nullable: true),
|
Properties = table.Column<string>(nullable: true),
|
||||||
RedirectUris = table.Column<string>(nullable: true),
|
RedirectUris = table.Column<string>(nullable: true),
|
||||||
Type = table.Column<string>(maxLength: 25, nullable: false),
|
Type = table.Column<string>(maxLength: 25, nullable: false),
|
||||||
ApplicationUserId = table.Column<string>(nullable: true, maxLength: maxLength)
|
ApplicationUserId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -47,7 +46,7 @@ namespace BTCPayServer.Migrations
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
||||||
Description = table.Column<string>(nullable: true),
|
Description = table.Column<string>(nullable: true),
|
||||||
DisplayName = table.Column<string>(nullable: true),
|
DisplayName = table.Column<string>(nullable: true),
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Name = table.Column<string>(maxLength: 200, nullable: false),
|
Name = table.Column<string>(maxLength: 200, nullable: false),
|
||||||
Properties = table.Column<string>(nullable: true),
|
Properties = table.Column<string>(nullable: true),
|
||||||
Resources = table.Column<string>(nullable: true)
|
Resources = table.Column<string>(nullable: true)
|
||||||
|
@ -61,9 +60,9 @@ namespace BTCPayServer.Migrations
|
||||||
name: "OpenIddictAuthorizations",
|
name: "OpenIddictAuthorizations",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
ApplicationId = table.Column<string>(nullable: true, maxLength: maxLength),
|
ApplicationId = table.Column<string>(nullable: true, maxLength: null),
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Properties = table.Column<string>(nullable: true),
|
Properties = table.Column<string>(nullable: true),
|
||||||
Scopes = table.Column<string>(nullable: true),
|
Scopes = table.Column<string>(nullable: true),
|
||||||
Status = table.Column<string>(maxLength: 25, nullable: false),
|
Status = table.Column<string>(maxLength: 25, nullable: false),
|
||||||
|
@ -85,12 +84,12 @@ namespace BTCPayServer.Migrations
|
||||||
name: "OpenIddictTokens",
|
name: "OpenIddictTokens",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
ApplicationId = table.Column<string>(nullable: true, maxLength: maxLength),
|
ApplicationId = table.Column<string>(nullable: true, maxLength: null),
|
||||||
AuthorizationId = table.Column<string>(nullable: true, maxLength: maxLength),
|
AuthorizationId = table.Column<string>(nullable: true, maxLength: null),
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
||||||
CreationDate = table.Column<DateTimeOffset>(nullable: true),
|
CreationDate = table.Column<DateTimeOffset>(nullable: true),
|
||||||
ExpirationDate = table.Column<DateTimeOffset>(nullable: true),
|
ExpirationDate = table.Column<DateTimeOffset>(nullable: true),
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Payload = table.Column<string>(nullable: true),
|
Payload = table.Column<string>(nullable: true),
|
||||||
Properties = table.Column<string>(nullable: true),
|
Properties = table.Column<string>(nullable: true),
|
||||||
ReferenceId = table.Column<string>(maxLength: 100, nullable: true),
|
ReferenceId = table.Column<string>(maxLength: 100, nullable: true),
|
||||||
|
|
|
@ -11,16 +11,15 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Files",
|
name: "Files",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
FileName = table.Column<string>(nullable: true),
|
FileName = table.Column<string>(nullable: true),
|
||||||
StorageFileName = table.Column<string>(nullable: true),
|
StorageFileName = table.Column<string>(nullable: true),
|
||||||
Timestamp = table.Column<DateTime>(nullable: false),
|
Timestamp = table.Column<DateTime>(nullable: false),
|
||||||
ApplicationUserId = table.Column<string>(nullable: true, maxLength: maxLength)
|
ApplicationUserId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,26 +9,22 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class AddU2fDevices : Migration
|
public partial class AddU2fDevices : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Facade",
|
name: "Facade",
|
||||||
table: "PairedSINData");
|
table: "PairedSINData");
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "U2FDevices",
|
name: "U2FDevices",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Name = table.Column<string>(nullable: true),
|
Name = table.Column<string>(nullable: true),
|
||||||
KeyHandle = table.Column<byte[]>(nullable: false),
|
KeyHandle = table.Column<byte[]>(nullable: false),
|
||||||
PublicKey = table.Column<byte[]>(nullable: false),
|
PublicKey = table.Column<byte[]>(nullable: false),
|
||||||
AttestationCert = table.Column<byte[]>(nullable: false),
|
AttestationCert = table.Column<byte[]>(nullable: false),
|
||||||
Counter = table.Column<int>(nullable: false),
|
Counter = table.Column<int>(nullable: false),
|
||||||
ApplicationUserId = table.Column<string>(nullable: true, maxLength: maxLength)
|
ApplicationUserId = table.Column<string>(nullable: true, maxLength: null)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -52,8 +48,6 @@ namespace BTCPayServer.Migrations
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "U2FDevices");
|
name: "U2FDevices");
|
||||||
//if it did not support dropping it, then it is still here and re-adding it would throw
|
//if it did not support dropping it, then it is still here and re-adding it would throw
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Facade",
|
name: "Facade",
|
||||||
table: "PairedSINData",
|
table: "PairedSINData",
|
||||||
|
@ -61,4 +55,3 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<DateTimeOffset>(
|
migrationBuilder.AddColumn<DateTimeOffset>(
|
||||||
name: "Created",
|
name: "Created",
|
||||||
table: "PaymentRequests",
|
table: "PaymentRequests",
|
||||||
|
|
|
@ -10,12 +10,11 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Wallets",
|
name: "Wallets",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Blob = table.Column<byte[]>(nullable: true)
|
Blob = table.Column<byte[]>(nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
|
@ -27,8 +26,8 @@ namespace BTCPayServer.Migrations
|
||||||
name: "WalletTransactions",
|
name: "WalletTransactions",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
WalletDataId = table.Column<string>(nullable: false, maxLength: maxLength),
|
WalletDataId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
TransactionId = table.Column<string>(nullable: false, maxLength: maxLength),
|
TransactionId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Labels = table.Column<string>(nullable: true),
|
Labels = table.Column<string>(nullable: true),
|
||||||
Blob = table.Column<byte[]>(nullable: true)
|
Blob = table.Column<byte[]>(nullable: true)
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,8 +10,6 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class OpenIddictUpdate : Migration
|
public partial class OpenIddictUpdate : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (!migrationBuilder.IsSqlite())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.AlterColumn<string>(
|
migrationBuilder.AlterColumn<string>(
|
||||||
name: "Subject",
|
name: "Subject",
|
||||||
|
@ -28,74 +26,6 @@ namespace BTCPayServer.Migrations
|
||||||
nullable: true,
|
nullable: true,
|
||||||
oldClrType: typeof(string),
|
oldClrType: typeof(string),
|
||||||
oldMaxLength: 450);
|
oldMaxLength: 450);
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReplaceOldTable(migrationBuilder, s =>
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: s,
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ApplicationId = table.Column<string>(nullable: true, maxLength: null),
|
|
||||||
AuthorizationId = table.Column<string>(nullable: true, maxLength: null),
|
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
|
||||||
CreationDate = table.Column<DateTimeOffset>(nullable: true),
|
|
||||||
ExpirationDate = table.Column<DateTimeOffset>(nullable: true),
|
|
||||||
Id = table.Column<string>(nullable: false, maxLength: null),
|
|
||||||
Payload = table.Column<string>(nullable: true),
|
|
||||||
Properties = table.Column<string>(nullable: true),
|
|
||||||
ReferenceId = table.Column<string>(maxLength: 100, nullable: true),
|
|
||||||
Status = table.Column<string>(maxLength: 25, nullable: false),
|
|
||||||
Subject = table.Column<string>(maxLength: 450, nullable: true),
|
|
||||||
Type = table.Column<string>(maxLength: 25, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OpenIddictTokens", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId",
|
|
||||||
column: x => x.ApplicationId,
|
|
||||||
principalTable: "OpenIddictApplications",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId",
|
|
||||||
column: x => x.AuthorizationId,
|
|
||||||
principalTable: "OpenIddictAuthorizations",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
}, "OpenIddictTokens");
|
|
||||||
|
|
||||||
ReplaceOldTable(migrationBuilder, s =>
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: s,
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ApplicationId = table.Column<string>(nullable: true, maxLength: null),
|
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
|
||||||
Id = table.Column<string>(nullable: false, maxLength: null),
|
|
||||||
Properties = table.Column<string>(nullable: true),
|
|
||||||
Scopes = table.Column<string>(nullable: true),
|
|
||||||
Status = table.Column<string>(maxLength: 25, nullable: false),
|
|
||||||
Subject = table.Column<string>(maxLength: 450, nullable: true),
|
|
||||||
Type = table.Column<string>(maxLength: 25, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId",
|
|
||||||
column: x => x.ApplicationId,
|
|
||||||
principalTable: "OpenIddictApplications",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
}, "OpenIddictAuthorizations");
|
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Requirements",
|
name: "Requirements",
|
||||||
|
@ -104,8 +34,6 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (!migrationBuilder.IsSqlite())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Requirements",
|
name: "Requirements",
|
||||||
|
@ -129,116 +57,5 @@ namespace BTCPayServer.Migrations
|
||||||
oldMaxLength: 450,
|
oldMaxLength: 450,
|
||||||
oldNullable: true);
|
oldNullable: true);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ReplaceOldTable(migrationBuilder, s =>
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: s,
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ApplicationId = table.Column<string>(nullable: true, maxLength: null),
|
|
||||||
AuthorizationId = table.Column<string>(nullable: true, maxLength: null),
|
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
|
||||||
CreationDate = table.Column<DateTimeOffset>(nullable: true),
|
|
||||||
ExpirationDate = table.Column<DateTimeOffset>(nullable: true),
|
|
||||||
Id = table.Column<string>(nullable: false, maxLength: null),
|
|
||||||
Payload = table.Column<string>(nullable: true),
|
|
||||||
Properties = table.Column<string>(nullable: true),
|
|
||||||
ReferenceId = table.Column<string>(maxLength: 100, nullable: true),
|
|
||||||
Status = table.Column<string>(maxLength: 25, nullable: false),
|
|
||||||
Subject = table.Column<string>(maxLength: 450, nullable: false),
|
|
||||||
Type = table.Column<string>(maxLength: 25, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OpenIddictTokens", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId",
|
|
||||||
column: x => x.ApplicationId,
|
|
||||||
principalTable: "OpenIddictApplications",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId",
|
|
||||||
column: x => x.AuthorizationId,
|
|
||||||
principalTable: "OpenIddictAuthorizations",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
}, "OpenIddictTokens", "WHERE Subject IS NOT NULL");
|
|
||||||
|
|
||||||
ReplaceOldTable(migrationBuilder, s =>
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: s,
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ApplicationId = table.Column<string>(nullable: true, maxLength: null),
|
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
|
||||||
Id = table.Column<string>(nullable: false, maxLength: null),
|
|
||||||
Properties = table.Column<string>(nullable: true),
|
|
||||||
Scopes = table.Column<string>(nullable: true),
|
|
||||||
Status = table.Column<string>(maxLength: 25, nullable: false),
|
|
||||||
Subject = table.Column<string>(maxLength: 450, nullable: false),
|
|
||||||
Type = table.Column<string>(maxLength: 25, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId",
|
|
||||||
column: x => x.ApplicationId,
|
|
||||||
principalTable: "OpenIddictApplications",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
}, "OpenIddictAuthorizations", "WHERE Subject IS NOT NULL");
|
|
||||||
|
|
||||||
ReplaceOldTable(migrationBuilder, s =>
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: s,
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ClientId = table.Column<string>(maxLength: 100, nullable: false),
|
|
||||||
ClientSecret = table.Column<string>(nullable: true),
|
|
||||||
ConcurrencyToken = table.Column<string>(maxLength: 50, nullable: true),
|
|
||||||
ConsentType = table.Column<string>(nullable: true),
|
|
||||||
DisplayName = table.Column<string>(nullable: true),
|
|
||||||
Id = table.Column<string>(nullable: false, maxLength: null),
|
|
||||||
Permissions = table.Column<string>(nullable: true),
|
|
||||||
PostLogoutRedirectUris = table.Column<string>(nullable: true),
|
|
||||||
Properties = table.Column<string>(nullable: true),
|
|
||||||
RedirectUris = table.Column<string>(nullable: true),
|
|
||||||
Type = table.Column<string>(maxLength: 25, nullable: false),
|
|
||||||
ApplicationUserId = table.Column<string>(nullable: true, maxLength: null)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OpenIddictApplications", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OpenIddictApplications_AspNetUsers_ApplicationUserId",
|
|
||||||
column: x => x.ApplicationUserId,
|
|
||||||
principalTable: "AspNetUsers",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
}, "OpenIddictApplications", "",
|
|
||||||
"ClientId, ClientSecret, ConcurrencyToken, ConsentType, DisplayName, Id, Permissions, PostLogoutRedirectUris, Properties, RedirectUris, Type, ApplicationUserId");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ReplaceOldTable(MigrationBuilder migrationBuilder, Action<string> createTable, string tableName,
|
|
||||||
string whereClause = "", string columns = "*")
|
|
||||||
{
|
|
||||||
createTable.Invoke($"New_{tableName}");
|
|
||||||
migrationBuilder.Sql(
|
|
||||||
$"INSERT INTO New_{tableName} {(columns == "*" ? string.Empty : $"({columns})")}SELECT {columns} FROM {tableName} {whereClause};");
|
|
||||||
migrationBuilder.Sql("PRAGMA foreign_keys=\"0\"", true);
|
|
||||||
migrationBuilder.Sql($"DROP TABLE {tableName}", true);
|
|
||||||
migrationBuilder.Sql($"ALTER TABLE New_{tableName} RENAME TO {tableName}", true);
|
|
||||||
migrationBuilder.Sql("PRAGMA foreign_keys=\"1\"", true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "IX_ApiKeys_UserId",
|
name: "IX_ApiKeys_UserId",
|
||||||
table: "ApiKeys",
|
table: "ApiKeys",
|
||||||
column: "UserId");
|
column: "UserId");
|
||||||
if (this.SupportAddForeignKey(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_ApiKeys_AspNetUsers_UserId",
|
name: "FK_ApiKeys_AspNetUsers_UserId",
|
||||||
table: "ApiKeys",
|
table: "ApiKeys",
|
||||||
|
@ -41,22 +40,17 @@ namespace BTCPayServer.Migrations
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropForeignKey(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropForeignKey(
|
||||||
name: "FK_ApiKeys_AspNetUsers_UserId",
|
name: "FK_ApiKeys_AspNetUsers_UserId",
|
||||||
table: "ApiKeys");
|
table: "ApiKeys");
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
migrationBuilder.DropIndex(
|
||||||
name: "IX_ApiKeys_UserId",
|
name: "IX_ApiKeys_UserId",
|
||||||
table: "ApiKeys");
|
table: "ApiKeys");
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Permissions",
|
name: "Permissions",
|
||||||
table: "ApiKeys");
|
table: "ApiKeys");
|
||||||
|
@ -71,4 +65,3 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -26,13 +26,12 @@ namespace BTCPayServer.Migrations
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "OpenIddictApplications",
|
name: "OpenIddictApplications",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: null),
|
||||||
ApplicationUserId = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxLength),
|
ApplicationUserId = table.Column<string>(type: "TEXT", nullable: true, maxLength: null),
|
||||||
ClientId = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
ClientId = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
||||||
ClientSecret = table.Column<string>(type: "TEXT", nullable: true),
|
ClientSecret = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
||||||
|
@ -60,7 +59,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "OpenIddictScopes",
|
name: "OpenIddictScopes",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: null),
|
||||||
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
||||||
Description = table.Column<string>(type: "TEXT", nullable: true),
|
Description = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
DisplayName = table.Column<string>(type: "TEXT", nullable: true),
|
DisplayName = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
@ -77,8 +76,8 @@ namespace BTCPayServer.Migrations
|
||||||
name: "OpenIddictAuthorizations",
|
name: "OpenIddictAuthorizations",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: null),
|
||||||
ApplicationId = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxLength),
|
ApplicationId = table.Column<string>(type: "TEXT", nullable: true, maxLength: null),
|
||||||
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
||||||
Properties = table.Column<string>(type: "TEXT", nullable: true),
|
Properties = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
Scopes = table.Column<string>(type: "TEXT", nullable: true),
|
Scopes = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
@ -101,9 +100,9 @@ namespace BTCPayServer.Migrations
|
||||||
name: "OpenIddictTokens",
|
name: "OpenIddictTokens",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: null),
|
||||||
ApplicationId = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxLength),
|
ApplicationId = table.Column<string>(type: "TEXT", nullable: true, maxLength: null),
|
||||||
AuthorizationId = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxLength),
|
AuthorizationId = table.Column<string>(type: "TEXT", nullable: true, maxLength: null),
|
||||||
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
ConcurrencyToken = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
|
||||||
CreationDate = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
|
CreationDate = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
|
||||||
ExpirationDate = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
|
ExpirationDate = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
|
||||||
|
|
|
@ -9,13 +9,10 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class AddApiKeyBlob : Migration
|
public partial class AddApiKeyBlob : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Permissions",
|
name: "Permissions",
|
||||||
table: "ApiKeys");
|
table: "ApiKeys");
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<byte[]>(
|
migrationBuilder.AddColumn<byte[]>(
|
||||||
name: "Blob",
|
name: "Blob",
|
||||||
|
@ -24,13 +21,10 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Blob",
|
name: "Blob",
|
||||||
table: "ApiKeys");
|
table: "ApiKeys");
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Permissions",
|
name: "Permissions",
|
||||||
|
|
|
@ -23,8 +23,6 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Archived",
|
name: "Archived",
|
||||||
|
@ -35,4 +33,3 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "RefundAddresses");
|
name: "RefundAddresses");
|
||||||
|
@ -20,7 +19,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "CurrentRefundId",
|
name: "CurrentRefundId",
|
||||||
table: "Invoices",
|
table: "Invoices",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
maxLength: maxLength);
|
maxLength: null);
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Notifications",
|
name: "Notifications",
|
||||||
|
@ -76,7 +75,7 @@ namespace BTCPayServer.Migrations
|
||||||
PullPaymentDataId = table.Column<string>(maxLength: 30, nullable: true),
|
PullPaymentDataId = table.Column<string>(maxLength: 30, nullable: true),
|
||||||
State = table.Column<string>(maxLength: 20, nullable: false),
|
State = table.Column<string>(maxLength: 20, nullable: false),
|
||||||
PaymentMethodId = table.Column<string>(maxLength: 20, nullable: false),
|
PaymentMethodId = table.Column<string>(maxLength: 20, nullable: false),
|
||||||
Destination = table.Column<string>(maxLength: maxLength, nullable: true),
|
Destination = table.Column<string>(maxLength: null, nullable: true),
|
||||||
Blob = table.Column<byte[]>(nullable: true),
|
Blob = table.Column<byte[]>(nullable: true),
|
||||||
Proof = table.Column<byte[]>(nullable: true)
|
Proof = table.Column<byte[]>(nullable: true)
|
||||||
},
|
},
|
||||||
|
@ -95,8 +94,8 @@ namespace BTCPayServer.Migrations
|
||||||
name: "Refunds",
|
name: "Refunds",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
InvoiceDataId = table.Column<string>(maxLength: maxLength, nullable: false),
|
InvoiceDataId = table.Column<string>(maxLength: null, nullable: false),
|
||||||
PullPaymentDataId = table.Column<string>(maxLength: maxLength, nullable: false)
|
PullPaymentDataId = table.Column<string>(maxLength: null, nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -151,7 +150,6 @@ namespace BTCPayServer.Migrations
|
||||||
table: "Refunds",
|
table: "Refunds",
|
||||||
column: "PullPaymentDataId");
|
column: "PullPaymentDataId");
|
||||||
|
|
||||||
if (this.SupportAddForeignKey(this.ActiveProvider))
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_Invoices_Refunds_Id_CurrentRefundId",
|
name: "FK_Invoices_Refunds_Id_CurrentRefundId",
|
||||||
table: "Invoices",
|
table: "Invoices",
|
||||||
|
|
|
@ -19,14 +19,10 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Severity",
|
name: "Severity",
|
||||||
table: "InvoiceEvents");
|
table: "InvoiceEvents");
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,10 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropColumn(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "Created",
|
name: "Created",
|
||||||
table: "AspNetUsers");
|
table: "AspNetUsers");
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class u2fDeviceCascade : Migration
|
public partial class u2fDeviceCascade : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropForeignKey(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropForeignKey(
|
||||||
name: "FK_U2FDevices_AspNetUsers_ApplicationUserId",
|
name: "FK_U2FDevices_AspNetUsers_ApplicationUserId",
|
||||||
|
@ -24,11 +22,8 @@ namespace BTCPayServer.Migrations
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (this.SupportDropForeignKey(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropForeignKey(
|
||||||
name: "FK_U2FDevices_AspNetUsers_ApplicationUserId",
|
name: "FK_U2FDevices_AspNetUsers_ApplicationUserId",
|
||||||
|
@ -44,4 +39,3 @@ namespace BTCPayServer.Migrations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -9,8 +9,6 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class invoicesorderindex : Migration
|
public partial class invoicesorderindex : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (!migrationBuilder.IsSqlite())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.AlterColumn<string>(
|
migrationBuilder.AlterColumn<string>(
|
||||||
name: "OrderId",
|
name: "OrderId",
|
||||||
|
@ -18,7 +16,6 @@ namespace BTCPayServer.Migrations
|
||||||
maxLength: 100,
|
maxLength: 100,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
oldClrType: typeof(string));
|
oldClrType: typeof(string));
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Invoices_OrderId",
|
name: "IX_Invoices_OrderId",
|
||||||
|
|
|
@ -11,14 +11,13 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Fido2Credentials",
|
name: "Fido2Credentials",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Name = table.Column<string>(nullable: true),
|
Name = table.Column<string>(nullable: true),
|
||||||
ApplicationUserId = table.Column<string>(nullable: true, maxLength: maxLength),
|
ApplicationUserId = table.Column<string>(nullable: true, maxLength: null),
|
||||||
Blob = table.Column<byte[]>(nullable: true),
|
Blob = table.Column<byte[]>(nullable: true),
|
||||||
Type = table.Column<int>(nullable: false)
|
Type = table.Column<int>(nullable: false)
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,19 +17,18 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "StoreDataId",
|
name: "StoreDataId",
|
||||||
table: "Payouts",
|
table: "Payouts",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
maxLength: maxLength);
|
maxLength: null);
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "PayoutProcessors",
|
name: "PayoutProcessors",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxLength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
StoreId = table.Column<string>(nullable: true, maxLength: maxLength),
|
StoreId = table.Column<string>(nullable: true, maxLength: null),
|
||||||
PaymentMethod = table.Column<string>(nullable: true),
|
PaymentMethod = table.Column<string>(nullable: true),
|
||||||
Processor = table.Column<string>(nullable: true),
|
Processor = table.Column<string>(nullable: true),
|
||||||
Blob = table.Column<byte[]>(nullable: true)
|
Blob = table.Column<byte[]>(nullable: true)
|
||||||
|
@ -54,8 +53,7 @@ namespace BTCPayServer.Migrations
|
||||||
name: "IX_PayoutProcessors_StoreId",
|
name: "IX_PayoutProcessors_StoreId",
|
||||||
table: "PayoutProcessors",
|
table: "PayoutProcessors",
|
||||||
column: "StoreId");
|
column: "StoreId");
|
||||||
if (this.SupportAddForeignKey(ActiveProvider))
|
|
||||||
{
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_Payouts_Stores_StoreDataId",
|
name: "FK_Payouts_Stores_StoreDataId",
|
||||||
table: "Payouts",
|
table: "Payouts",
|
||||||
|
@ -64,13 +62,9 @@ namespace BTCPayServer.Migrations
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
if (this.SupportDropForeignKey(ActiveProvider))
|
|
||||||
{
|
|
||||||
|
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropForeignKey(
|
||||||
name: "FK_Payouts_Stores_StoreDataId",
|
name: "FK_Payouts_Stores_StoreDataId",
|
||||||
table: "Payouts");
|
table: "Payouts");
|
||||||
|
@ -81,13 +75,9 @@ namespace BTCPayServer.Migrations
|
||||||
migrationBuilder.DropIndex(
|
migrationBuilder.DropIndex(
|
||||||
name: "IX_Payouts_StoreDataId",
|
name: "IX_Payouts_StoreDataId",
|
||||||
table: "Payouts");
|
table: "Payouts");
|
||||||
}
|
|
||||||
if(this.SupportDropColumn(ActiveProvider))
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
migrationBuilder.DropColumn(
|
||||||
name: "StoreDataId",
|
name: "StoreDataId",
|
||||||
table: "Payouts");
|
table: "Payouts");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -17,13 +17,12 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxLength = this.IsMySql(migrationBuilder.ActiveProvider) ? (int?)255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "LightningAddresses",
|
name: "LightningAddresses",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Username = table.Column<string>(nullable: false, maxLength: maxLength),
|
Username = table.Column<string>(nullable: false, maxLength: null),
|
||||||
StoreDataId = table.Column<string>(nullable: false, maxLength: maxLength),
|
StoreDataId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Blob = table.Column<byte[]>( nullable: true)
|
Blob = table.Column<byte[]>( nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
|
|
|
@ -14,14 +14,13 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxlength = migrationBuilder.IsMySql() ? 255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "StoreSettings",
|
name: "StoreSettings",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Name = table.Column<string>(nullable: false, maxLength: maxlength),
|
Name = table.Column<string>(nullable: false, maxLength: null),
|
||||||
StoreId = table.Column<string>(nullable: false, maxLength: maxlength),
|
StoreId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Value = table.Column<string>(type: migrationBuilder.IsNpgsql() ? "JSONB" : "TEXT", nullable: true)
|
Value = table.Column<string>(type: "JSONB", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,16 +17,14 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxlength = migrationBuilder.IsMySql() ? 255 : null;
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "WalletObjects",
|
name: "WalletObjects",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
WalletId = table.Column<string>(nullable: false, maxLength: maxlength),
|
WalletId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Type = table.Column<string>(nullable: false, maxLength: maxlength),
|
Type = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Id = table.Column<string>(nullable: false, maxLength: maxlength),
|
Id = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Data = table.Column<string>(type: migrationBuilder.IsNpgsql() ? "JSONB" : "TEXT", nullable: true)
|
Data = table.Column<string>(type: "JSONB", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -37,18 +35,16 @@ namespace BTCPayServer.Migrations
|
||||||
table: "WalletObjects",
|
table: "WalletObjects",
|
||||||
columns: new[] { "Type", "Id" });
|
columns: new[] { "Type", "Id" });
|
||||||
|
|
||||||
|
|
||||||
maxlength = migrationBuilder.IsMySql() ? 100 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "WalletObjectLinks",
|
name: "WalletObjectLinks",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
WalletId = table.Column<string>(nullable: false, maxLength: maxlength),
|
WalletId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
AType = table.Column<string>(nullable: false, maxLength: maxlength),
|
AType = table.Column<string>(nullable: false, maxLength: null),
|
||||||
AId = table.Column<string>(nullable: false, maxLength: maxlength),
|
AId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
BType = table.Column<string>(nullable: false, maxLength: maxlength),
|
BType = table.Column<string>(nullable: false, maxLength: null),
|
||||||
BId = table.Column<string>(nullable: false, maxLength: maxlength),
|
BId = table.Column<string>(nullable: false, maxLength: null),
|
||||||
Data = table.Column<string>(type: migrationBuilder.IsNpgsql() ? "JSONB" : "TEXT", nullable: true)
|
Data = table.Column<string>(type: "JSONB", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,13 +15,10 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class jsonb : Migration
|
public partial class jsonb : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (migrationBuilder.IsNpgsql())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.Sql("ALTER TABLE \"Settings\" ALTER COLUMN \"Value\" TYPE JSONB USING \"Value\"::JSONB");
|
migrationBuilder.Sql("ALTER TABLE \"Settings\" ALTER COLUMN \"Value\" TYPE JSONB USING \"Value\"::JSONB");
|
||||||
migrationBuilder.Sql("ALTER TABLE \"Stores\" ALTER COLUMN \"StoreBlob\" TYPE JSONB USING regexp_replace(convert_from(\"StoreBlob\",'UTF8'), '\\\\u0000', '', 'g')::JSONB");
|
migrationBuilder.Sql("ALTER TABLE \"Stores\" ALTER COLUMN \"StoreBlob\" TYPE JSONB USING regexp_replace(convert_from(\"StoreBlob\",'UTF8'), '\\\\u0000', '', 'g')::JSONB");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,12 +15,9 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class migrateoldratesource : Migration
|
public partial class migrateoldratesource : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (migrationBuilder.IsNpgsql())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.Sql("UPDATE \"Stores\" SET \"StoreBlob\"=jsonb_set(\"StoreBlob\", \'{preferredExchange}\', \'{\"oasis_trade\": \"oasisdev\", \"gdax\":\"coinbasepro\", \"coinaverage\":\"coingecko\"}\'::jsonb->(\"StoreBlob\"->>\'preferredExchange\')) WHERE \"StoreBlob\"->>\'preferredExchange\' = ANY (ARRAY[\'oasis_trade\', \'gdax\', \'coinaverage\']);");
|
migrationBuilder.Sql("UPDATE \"Stores\" SET \"StoreBlob\"=jsonb_set(\"StoreBlob\", \'{preferredExchange}\', \'{\"oasis_trade\": \"oasisdev\", \"gdax\":\"coinbasepro\", \"coinaverage\":\"coingecko\"}\'::jsonb->(\"StoreBlob\"->>\'preferredExchange\')) WHERE \"StoreBlob\"->>\'preferredExchange\' = ANY (ARRAY[\'oasis_trade\', \'gdax\', \'coinaverage\']);");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,15 +16,14 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
int? maxlength = migrationBuilder.IsMySql() ? 255 : null;
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Forms",
|
name: "Forms",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: maxlength),
|
Id = table.Column<string>(type: "TEXT", nullable: false, maxLength: null),
|
||||||
Name = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxlength),
|
Name = table.Column<string>(type: "TEXT", nullable: true, maxLength: null),
|
||||||
StoreId = table.Column<string>(type: "TEXT", nullable: true, maxLength: maxlength),
|
StoreId = table.Column<string>(type: "TEXT", nullable: true, maxLength: null),
|
||||||
Config = table.Column<string>(type: migrationBuilder.IsNpgsql() ? "JSONB" : "TEXT", nullable: true),
|
Config = table.Column<string>(type: "JSONB", nullable: true),
|
||||||
Public = table.Column<bool>(nullable: false)
|
Public = table.Column<bool>(nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
|
|
|
@ -14,76 +14,75 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
var type = migrationBuilder.IsNpgsql() ? "JSONB" : "TEXT";
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "Webhooks",
|
table: "Webhooks",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "WebhookDeliveries",
|
table: "WebhookDeliveries",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "PaymentRequests",
|
table: "PaymentRequests",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "Notifications",
|
table: "Notifications",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "LightningAddresses",
|
table: "LightningAddresses",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "Fido2Credentials",
|
table: "Fido2Credentials",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "AspNetUsers",
|
table: "AspNetUsers",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "ApiKeys",
|
table: "ApiKeys",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "Invoices",
|
table: "Invoices",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "Payments",
|
table: "Payments",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "PayoutProcessors",
|
table: "PayoutProcessors",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
name: "Blob2",
|
name: "Blob2",
|
||||||
table: "CustodianAccount",
|
table: "CustodianAccount",
|
||||||
type: type,
|
type: "JSONB",
|
||||||
nullable: true);
|
nullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
migrationBuilder.AddColumn<string>(
|
||||||
|
|
|
@ -15,12 +15,9 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class jsonb2 : Migration
|
public partial class jsonb2 : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (migrationBuilder.IsNpgsql())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.Sql("ALTER TABLE \"Stores\" ALTER COLUMN \"DerivationStrategies\" TYPE JSONB USING \"DerivationStrategies\"::JSONB");
|
migrationBuilder.Sql("ALTER TABLE \"Stores\" ALTER COLUMN \"DerivationStrategies\" TYPE JSONB USING \"DerivationStrategies\"::JSONB");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,13 +15,10 @@ namespace BTCPayServer.Migrations
|
||||||
public partial class fixmaxlength : Migration
|
public partial class fixmaxlength : Migration
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
if (migrationBuilder.IsNpgsql())
|
|
||||||
{
|
{
|
||||||
migrationBuilder.Sql("ALTER TABLE \"InvoiceSearches\" ALTER COLUMN \"Value\" TYPE TEXT USING \"Value\"::TEXT;");
|
migrationBuilder.Sql("ALTER TABLE \"InvoiceSearches\" ALTER COLUMN \"Value\" TYPE TEXT USING \"Value\"::TEXT;");
|
||||||
migrationBuilder.Sql("ALTER TABLE \"Invoices\" ALTER COLUMN \"OrderId\" TYPE TEXT USING \"OrderId\"::TEXT;");
|
migrationBuilder.Sql("ALTER TABLE \"Invoices\" ALTER COLUMN \"OrderId\" TYPE TEXT USING \"OrderId\"::TEXT;");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,6 @@ namespace BTCPayServer.Migrations
|
||||||
{
|
{
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
var permissionsType = migrationBuilder.IsNpgsql() ? "TEXT[]" : "TEXT";
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "StoreRoles",
|
name: "StoreRoles",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
|
@ -25,7 +24,7 @@ namespace BTCPayServer.Migrations
|
||||||
Id = table.Column<string>(type: "TEXT", nullable: false),
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
StoreDataId = table.Column<string>(type: "TEXT", nullable: true),
|
StoreDataId = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
Role = table.Column<string>(type: "TEXT", nullable: false),
|
Role = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
Permissions = table.Column<string>(type: permissionsType, nullable: false)
|
Permissions = table.Column<string>(type: "TEXT[]", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
|
@ -44,42 +43,32 @@ namespace BTCPayServer.Migrations
|
||||||
columns: new[] { "StoreDataId", "Role" },
|
columns: new[] { "StoreDataId", "Role" },
|
||||||
unique: true);
|
unique: true);
|
||||||
|
|
||||||
object GetPermissionsData(string[] permissions)
|
|
||||||
{
|
|
||||||
if (migrationBuilder.IsNpgsql())
|
|
||||||
return permissions;
|
|
||||||
return JsonConvert.SerializeObject(permissions);
|
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.InsertData(
|
migrationBuilder.InsertData(
|
||||||
"StoreRoles",
|
"StoreRoles",
|
||||||
columns: new[] { "Id", "Role", "Permissions" },
|
columns: new[] { "Id", "Role", "Permissions" },
|
||||||
columnTypes: new[] { "TEXT", "TEXT", permissionsType },
|
columnTypes: new[] { "TEXT", "TEXT", "TEXT[]" },
|
||||||
values: new object[,]
|
values: new object[,]
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
"Owner", "Owner", GetPermissionsData(new[]
|
"Owner", "Owner", new[]
|
||||||
{
|
{
|
||||||
"btcpay.store.canmodifystoresettings",
|
"btcpay.store.canmodifystoresettings",
|
||||||
"btcpay.store.cantradecustodianaccount",
|
"btcpay.store.cantradecustodianaccount",
|
||||||
"btcpay.store.canwithdrawfromcustodianaccount",
|
"btcpay.store.canwithdrawfromcustodianaccount",
|
||||||
"btcpay.store.candeposittocustodianaccount"
|
"btcpay.store.candeposittocustodianaccount"
|
||||||
})
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Guest", "Guest", GetPermissionsData(new[]
|
"Guest", "Guest", new[]
|
||||||
{
|
{
|
||||||
"btcpay.store.canviewstoresettings",
|
"btcpay.store.canviewstoresettings",
|
||||||
"btcpay.store.canmodifyinvoices",
|
"btcpay.store.canmodifyinvoices",
|
||||||
"btcpay.store.canviewcustodianaccounts",
|
"btcpay.store.canviewcustodianaccounts",
|
||||||
"btcpay.store.candeposittocustodianaccount"
|
"btcpay.store.candeposittocustodianaccount"
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.SupportAddForeignKey(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_UserStore_StoreRoles_Role",
|
name: "FK_UserStore_StoreRoles_Role",
|
||||||
table: "UserStore",
|
table: "UserStore",
|
||||||
|
@ -87,17 +76,12 @@ namespace BTCPayServer.Migrations
|
||||||
principalTable: "StoreRoles",
|
principalTable: "StoreRoles",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
|
||||||
|
|
||||||
if (this.SupportDropForeignKey(migrationBuilder.ActiveProvider))
|
|
||||||
{
|
{
|
||||||
migrationBuilder.DropForeignKey(
|
migrationBuilder.DropForeignKey(
|
||||||
name: "FK_UserStore_StoreRoles_Role",
|
name: "FK_UserStore_StoreRoles_Role",
|
||||||
table: "UserStore");
|
table: "UserStore");
|
||||||
}
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "StoreRoles");
|
name: "StoreRoles");
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,28 +0,0 @@
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Migrations
|
|
||||||
{
|
|
||||||
public static class MigrationsExtensions
|
|
||||||
{
|
|
||||||
public static bool SupportDropColumn(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
|
|
||||||
{
|
|
||||||
return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
|
|
||||||
}
|
|
||||||
public static bool SupportAddForeignKey(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
|
|
||||||
{
|
|
||||||
return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
|
|
||||||
}
|
|
||||||
public static bool SupportDropForeignKey(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
|
|
||||||
{
|
|
||||||
return activeProvider != "Microsoft.EntityFrameworkCore.Sqlite";
|
|
||||||
}
|
|
||||||
public static bool SupportDropForeignKey(this DatabaseFacade facade)
|
|
||||||
{
|
|
||||||
return facade.ProviderName != "Microsoft.EntityFrameworkCore.Sqlite";
|
|
||||||
}
|
|
||||||
public static bool IsMySql(this Microsoft.EntityFrameworkCore.Migrations.Migration migration, string activeProvider)
|
|
||||||
{
|
|
||||||
return activeProvider == "Pomelo.EntityFrameworkCore.MySql";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1270,17 +1270,6 @@ bc1qfzu57kgu5jthl934f9xrdzzx8mmemx7gn07tf0grnvz504j6kzusu2v0ku
|
||||||
Assert.Contains("originalDeliveryId", serialized);
|
Assert.Contains("originalDeliveryId", serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task CanCreateSqlitedb()
|
|
||||||
{
|
|
||||||
if (File.Exists("temp.db"))
|
|
||||||
File.Delete("temp.db");
|
|
||||||
// This test sqlite can migrate
|
|
||||||
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
|
|
||||||
builder.UseSqlite("Data Source=temp.db");
|
|
||||||
await new ApplicationDbContext(builder.Options).Database.MigrateAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanUsePermission()
|
public void CanUsePermission()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4179,20 +4179,20 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Single(testObj.Links.Where(l => l.Id == "test1" && l.LinkData["testData"]?.Value<string>() == "lol"));
|
Assert.Single(testObj.Links.Where(l => l.Id == "test1" && l.LinkData["testData"]?.Value<string>() == "lol"));
|
||||||
Assert.Single(testObj.Links.Where(l => l.Id == "test1" && l.ObjectData is null));
|
Assert.Single(testObj.Links.Where(l => l.Id == "test1" && l.ObjectData is null));
|
||||||
|
|
||||||
async Task TestWalletRepository(bool useInefficient)
|
async Task TestWalletRepository()
|
||||||
{
|
{
|
||||||
// We should have 4 nodes, two `test` type and one `newtype`
|
// We should have 4 nodes, two `test` type and one `newtype`
|
||||||
// Only the node `test` `test` is connected to `test1`
|
// Only the node `test` `test` is connected to `test1`
|
||||||
var wid = new WalletId(admin.StoreId, "BTC");
|
var wid = new WalletId(admin.StoreId, "BTC");
|
||||||
var repo = tester.PayTester.GetService<WalletRepository>();
|
var repo = tester.PayTester.GetService<WalletRepository>();
|
||||||
var allObjects = await repo.GetWalletObjects(new(wid) { UseInefficientPath = useInefficient });
|
var allObjects = await repo.GetWalletObjects(new(wid));
|
||||||
var allObjectsNoWallet = await repo.GetWalletObjects((new() { UseInefficientPath = useInefficient }));
|
var allObjectsNoWallet = await repo.GetWalletObjects((new()));
|
||||||
var allObjectsNoWalletAndType = await repo.GetWalletObjects((new() { Type = "test", UseInefficientPath = useInefficient }));
|
var allObjectsNoWalletAndType = await repo.GetWalletObjects((new() { Type = "test" }));
|
||||||
var allTests = await repo.GetWalletObjects((new(wid, "test") { UseInefficientPath = useInefficient }));
|
var allTests = await repo.GetWalletObjects((new(wid, "test")));
|
||||||
var twoTests2 = await repo.GetWalletObjects((new(wid, "test", new[] { "test1", "test2", "test-unk" }) { UseInefficientPath = useInefficient }));
|
var twoTests2 = await repo.GetWalletObjects((new(wid, "test", new[] { "test1", "test2", "test-unk" })));
|
||||||
var oneTest = await repo.GetWalletObjects((new(wid, "test", new[] { "test" }) { UseInefficientPath = useInefficient }));
|
var oneTest = await repo.GetWalletObjects((new(wid, "test", new[] { "test" })));
|
||||||
var oneTestWithoutData = await repo.GetWalletObjects((new(wid, "test", new[] { "test" }) { UseInefficientPath = useInefficient, IncludeNeighbours = false }));
|
var oneTestWithoutData = await repo.GetWalletObjects((new(wid, "test", new[] { "test" }) { IncludeNeighbours = false }));
|
||||||
var idsTypes = await repo.GetWalletObjects((new(wid) { TypesIds = new[] { new ObjectTypeId("test", "test1"), new ObjectTypeId("test", "test2") }, UseInefficientPath = useInefficient }));
|
var idsTypes = await repo.GetWalletObjects((new(wid) { TypesIds = new[] { new ObjectTypeId("test", "test1"), new ObjectTypeId("test", "test2") }}));
|
||||||
|
|
||||||
Assert.Equal(4, allObjects.Count);
|
Assert.Equal(4, allObjects.Count);
|
||||||
// We are reusing a db in this test, as such we may have other wallets here.
|
// We are reusing a db in this test, as such we may have other wallets here.
|
||||||
|
@ -4206,8 +4206,7 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Null(oneTestWithoutData.First().Value.GetNeighbours().Select(n => n.Data).FirstOrDefault());
|
Assert.Null(oneTestWithoutData.First().Value.GetNeighbours().Select(n => n.Data).FirstOrDefault());
|
||||||
Assert.Equal(2, idsTypes.Count);
|
Assert.Equal(2, idsTypes.Count);
|
||||||
}
|
}
|
||||||
await TestWalletRepository(false);
|
await TestWalletRepository();
|
||||||
await TestWalletRepository(true);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
var allObjects = await client.GetOnChainWalletObjects(admin.StoreId, "BTC");
|
var allObjects = await client.GetOnChainWalletObjects(admin.StoreId, "BTC");
|
||||||
|
|
|
@ -36,9 +36,7 @@ namespace BTCPayServer.Configuration
|
||||||
app.Option("--signet | -signet", $"Use signet (deprecated, use --network instead)", CommandOptionType.BoolValue);
|
app.Option("--signet | -signet", $"Use signet (deprecated, use --network instead)", CommandOptionType.BoolValue);
|
||||||
app.Option("--chains | -c", $"Chains to support as a comma separated (default: btc; available: {chains})", CommandOptionType.SingleValue);
|
app.Option("--chains | -c", $"Chains to support as a comma separated (default: btc; available: {chains})", CommandOptionType.SingleValue);
|
||||||
app.Option("--postgres", $"Connection string to a PostgreSQL database", CommandOptionType.SingleValue);
|
app.Option("--postgres", $"Connection string to a PostgreSQL database", CommandOptionType.SingleValue);
|
||||||
app.Option("--mysql", $"DEPRECATED: Connection string to a MySQL database", CommandOptionType.SingleValue);
|
|
||||||
app.Option("--nocsp", $"Disable CSP (default false)", CommandOptionType.BoolValue);
|
app.Option("--nocsp", $"Disable CSP (default false)", CommandOptionType.BoolValue);
|
||||||
app.Option("--sqlitefile", $"DEPRECATED: File name to an SQLite database file inside the data directory", CommandOptionType.SingleValue);
|
|
||||||
app.Option("--deprecated", $"Allow deprecated settings (default:false)", CommandOptionType.BoolValue);
|
app.Option("--deprecated", $"Allow deprecated settings (default:false)", CommandOptionType.BoolValue);
|
||||||
app.Option("--externalservices", $"Links added to external services inside Server Settings / Services under the format service1:path2;service2:path2.(default: empty)", CommandOptionType.SingleValue);
|
app.Option("--externalservices", $"Links added to external services inside Server Settings / Services under the format service1:path2;service2:path2.(default: empty)", CommandOptionType.SingleValue);
|
||||||
app.Option("--rootpath", "The root path in the URL to access BTCPay (default: /)", CommandOptionType.SingleValue);
|
app.Option("--rootpath", "The root path in the URL to access BTCPay (default: /)", CommandOptionType.SingleValue);
|
||||||
|
@ -139,8 +137,6 @@ namespace BTCPayServer.Configuration
|
||||||
builder.AppendLine();
|
builder.AppendLine();
|
||||||
builder.AppendLine("### Database ###");
|
builder.AppendLine("### Database ###");
|
||||||
builder.AppendLine("#postgres=User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;");
|
builder.AppendLine("#postgres=User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;");
|
||||||
builder.AppendLine("#mysql=User ID=root;Password=myPassword;Host=localhost;Port=3306;Database=myDataBase;");
|
|
||||||
builder.AppendLine("#sqlitefile=sqlite.db");
|
|
||||||
builder.AppendLine();
|
builder.AppendLine();
|
||||||
builder.AppendLine("### NBXplorer settings ###");
|
builder.AppendLine("### NBXplorer settings ###");
|
||||||
foreach (var n in CreateBTCPayNetworkProvider(networkType).GetAll().OfType<BTCPayNetwork>())
|
foreach (var n in CreateBTCPayNetworkProvider(networkType).GetAll().OfType<BTCPayNetwork>())
|
||||||
|
|
|
@ -63,12 +63,6 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||||
{
|
{
|
||||||
return StoreNotFound();
|
return StoreNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_storeRepository.CanDeleteStores())
|
|
||||||
{
|
|
||||||
return this.CreateAPIError("unsupported",
|
|
||||||
"BTCPay Server is using a database server that does not allow you to remove stores.");
|
|
||||||
}
|
|
||||||
await _storeRepository.RemoveStore(storeId, _userManager.GetUserId(User));
|
await _storeRepository.RemoveStore(storeId, _userManager.GetUserId(User));
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,7 @@ public partial class UIStoresController
|
||||||
InvoiceExpiration = (int)storeBlob.InvoiceExpiration.TotalMinutes,
|
InvoiceExpiration = (int)storeBlob.InvoiceExpiration.TotalMinutes,
|
||||||
DefaultCurrency = storeBlob.DefaultCurrency,
|
DefaultCurrency = storeBlob.DefaultCurrency,
|
||||||
BOLT11Expiration = (long)storeBlob.RefundBOLT11Expiration.TotalDays,
|
BOLT11Expiration = (long)storeBlob.RefundBOLT11Expiration.TotalDays,
|
||||||
Archived = store.Archived,
|
Archived = store.Archived
|
||||||
CanDelete = _storeRepo.CanDeleteStores()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(vm);
|
return View(vm);
|
||||||
|
|
|
@ -24,8 +24,6 @@ namespace BTCPayServer.HostedServices
|
||||||
public async Task Do(CancellationToken cancellationToken)
|
public async Task Do(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await using var ctx = DbContextFactory.CreateContext();
|
await using var ctx = DbContextFactory.CreateContext();
|
||||||
if (!ctx.Database.IsNpgsql())
|
|
||||||
return;
|
|
||||||
var conn = ctx.Database.GetDbConnection();
|
var conn = ctx.Database.GetDbConnection();
|
||||||
bool pruned = false;
|
bool pruned = false;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
|
@ -145,9 +145,7 @@ namespace BTCPayServer.Hosting
|
||||||
services.TryAddSingleton<InvoicePaymentNotification>();
|
services.TryAddSingleton<InvoicePaymentNotification>();
|
||||||
services.TryAddSingleton<BTCPayServerOptions>(o =>
|
services.TryAddSingleton<BTCPayServerOptions>(o =>
|
||||||
o.GetRequiredService<IOptions<BTCPayServerOptions>>().Value);
|
o.GetRequiredService<IOptions<BTCPayServerOptions>>().Value);
|
||||||
// Don't move this StartupTask, we depend on it being right here
|
|
||||||
if (configuration["POSTGRES"] != null && (configuration["SQLITEFILE"] != null || configuration["MYSQL"] != null))
|
|
||||||
services.AddStartupTask<ToPostgresMigrationStartupTask>();
|
|
||||||
services.AddStartupTask<MigrationStartupTask>();
|
services.AddStartupTask<MigrationStartupTask>();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -184,24 +182,10 @@ namespace BTCPayServer.Hosting
|
||||||
(options, datadirs) =>
|
(options, datadirs) =>
|
||||||
{
|
{
|
||||||
var postgresConnectionString = configuration["postgres"];
|
var postgresConnectionString = configuration["postgres"];
|
||||||
var mySQLConnectionString = configuration["mysql"];
|
|
||||||
var sqliteFileName = configuration["sqlitefile"];
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(postgresConnectionString))
|
if (!string.IsNullOrEmpty(postgresConnectionString))
|
||||||
{
|
{
|
||||||
options.DatabaseType = DatabaseType.Postgres;
|
|
||||||
options.ConnectionString = postgresConnectionString;
|
options.ConnectionString = postgresConnectionString;
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(mySQLConnectionString))
|
|
||||||
{
|
|
||||||
options.DatabaseType = DatabaseType.MySQL;
|
|
||||||
options.ConnectionString = mySQLConnectionString;
|
|
||||||
}
|
|
||||||
else if (!string.IsNullOrEmpty(sqliteFileName))
|
|
||||||
{
|
|
||||||
options.DatabaseType = DatabaseType.Sqlite;
|
|
||||||
options.ConnectionString = "Data Source=" + datadirs.Value.ToDatadirFullPath(sqliteFileName);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("No database option was configured.");
|
throw new InvalidOperationException("No database option was configured.");
|
||||||
|
|
|
@ -372,12 +372,21 @@ namespace BTCPayServer.Hosting
|
||||||
private async Task FixSeqAfterSqliteMigration()
|
private async Task FixSeqAfterSqliteMigration()
|
||||||
{
|
{
|
||||||
await using var ctx = _DBContextFactory.CreateContext();
|
await using var ctx = _DBContextFactory.CreateContext();
|
||||||
if (!ctx.Database.IsNpgsql())
|
var state = await GetMigrationState(ctx);
|
||||||
return;
|
|
||||||
var state = await ToPostgresMigrationStartupTask.GetMigrationState(ctx);
|
|
||||||
if (state != "complete")
|
if (state != "complete")
|
||||||
return;
|
return;
|
||||||
await ToPostgresMigrationStartupTask.UpdateSequenceInvoiceSearch(ctx);
|
await UpdateSequenceInvoiceSearch(ctx);
|
||||||
|
}
|
||||||
|
static async Task<string> GetMigrationState(ApplicationDbContext postgresContext)
|
||||||
|
{
|
||||||
|
var o = (await postgresContext.Settings.FromSqlRaw("SELECT \"Id\", \"Value\" FROM \"Settings\" WHERE \"Id\"='MigrationData'").AsNoTracking().FirstOrDefaultAsync())?.Value;
|
||||||
|
if (o is null)
|
||||||
|
return null;
|
||||||
|
return JObject.Parse(o)["state"]?.Value<string>();
|
||||||
|
}
|
||||||
|
static async Task UpdateSequenceInvoiceSearch(ApplicationDbContext postgresContext)
|
||||||
|
{
|
||||||
|
await postgresContext.Database.ExecuteSqlRawAsync("SELECT SETVAL('\"InvoiceSearches_Id_seq\"', (SELECT max(\"Id\") FROM \"InvoiceSearches\"));");
|
||||||
}
|
}
|
||||||
private async Task MigrateAppYmlToJson()
|
private async Task MigrateAppYmlToJson()
|
||||||
{
|
{
|
||||||
|
@ -646,8 +655,6 @@ namespace BTCPayServer.Hosting
|
||||||
{
|
{
|
||||||
await using var ctx = _DBContextFactory.CreateContext();
|
await using var ctx = _DBContextFactory.CreateContext();
|
||||||
|
|
||||||
if (ctx.Database.IsNpgsql())
|
|
||||||
{
|
|
||||||
await ctx.Database.ExecuteSqlRawAsync(@"
|
await ctx.Database.ExecuteSqlRawAsync(@"
|
||||||
WITH cte AS (
|
WITH cte AS (
|
||||||
SELECT DISTINCT p.""Id"", pp.""StoreId"" FROM ""Payouts"" p
|
SELECT DISTINCT p.""Id"", pp.""StoreId"" FROM ""Payouts"" p
|
||||||
|
@ -660,22 +667,6 @@ FROM cte
|
||||||
WHERE cte.""Id""=p.""Id""
|
WHERE cte.""Id""=p.""Id""
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
var queryable = ctx.Payouts.Where(data => data.StoreDataId == null);
|
|
||||||
var count = await queryable.CountAsync();
|
|
||||||
_logger.LogInformation($"Migrating {count} payouts to have a store id explicitly");
|
|
||||||
for (int i = 0; i < count; i += 1000)
|
|
||||||
{
|
|
||||||
await queryable.Include(data => data.PullPaymentData).Skip(i).Take(1000)
|
|
||||||
.ForEachAsync(data => data.StoreDataId = data.PullPaymentData.StoreId);
|
|
||||||
|
|
||||||
await ctx.SaveChangesAsync();
|
|
||||||
|
|
||||||
_logger.LogInformation($"Migrated {i + 1000}/{count} payouts to have a store id explicitly");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task AddInitialUserBlob()
|
private async Task AddInitialUserBlob()
|
||||||
{
|
{
|
||||||
|
@ -944,11 +935,6 @@ retry:
|
||||||
{
|
{
|
||||||
var db = _DBContextFactory.CreateContext();
|
var db = _DBContextFactory.CreateContext();
|
||||||
await db.Database.MigrateAsync();
|
await db.Database.MigrateAsync();
|
||||||
if (db.Database.IsNpgsql())
|
|
||||||
{
|
|
||||||
if (await db.GetMigrationState() == "pending")
|
|
||||||
throw new ConfigException("This database hasn't been completely migrated, please retry migration by setting the BTCPAY_SQLITEFILE or BTCPAY_MYSQL setting on top of BTCPAY_POSTGRES");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Starting up
|
// Starting up
|
||||||
catch (ConfigException) { throw; }
|
catch (ConfigException) { throw; }
|
||||||
|
|
|
@ -1,296 +0,0 @@
|
||||||
#nullable enable
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Amazon.Runtime.Internal.Util;
|
|
||||||
using AngleSharp.Text;
|
|
||||||
using BTCPayServer.Abstractions.Contracts;
|
|
||||||
using BTCPayServer.Configuration;
|
|
||||||
using BTCPayServer.Data;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
using Microsoft.Data.Sqlite;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using MySqlConnector;
|
|
||||||
using NBXplorer;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Hosting
|
|
||||||
{
|
|
||||||
static class TopologySort
|
|
||||||
{
|
|
||||||
public static IEnumerable<ITable> OrderByTopology(this IEnumerable<ITable> tables)
|
|
||||||
{
|
|
||||||
var comparer = Comparer<ITable>.Create((a, b) => a.Name.CompareTo(b.Name));
|
|
||||||
return OrderByTopology(
|
|
||||||
tables,
|
|
||||||
t =>
|
|
||||||
{
|
|
||||||
if (t.Name == "Invoices")
|
|
||||||
return t.ForeignKeyConstraints.Select(f => f.PrincipalTable.Name).Where(f => f != "Refunds");
|
|
||||||
else
|
|
||||||
return t.ForeignKeyConstraints.Select(f => f.PrincipalTable.Name);
|
|
||||||
},
|
|
||||||
t => t.Name,
|
|
||||||
t => t,
|
|
||||||
comparer);
|
|
||||||
}
|
|
||||||
public static IEnumerable<TValue> OrderByTopology<T, TDepend, TValue>(
|
|
||||||
this IEnumerable<T> values,
|
|
||||||
Func<T, IEnumerable<TDepend>> dependsOn,
|
|
||||||
Func<T, TDepend> getKey,
|
|
||||||
Func<T, TValue> getValue,
|
|
||||||
IComparer<T>? solveTies = null) where T : notnull
|
|
||||||
{
|
|
||||||
var v = values.ToList();
|
|
||||||
return TopologicalSort(v, dependsOn, getKey, getValue, solveTies);
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<TValue> TopologicalSort<T, TDepend, TValue>(this IReadOnlyCollection<T> nodes,
|
|
||||||
Func<T, IEnumerable<TDepend>> dependsOn,
|
|
||||||
Func<T, TDepend> getKey,
|
|
||||||
Func<T, TValue> getValue,
|
|
||||||
IComparer<T>? solveTies = null) where T : notnull
|
|
||||||
{
|
|
||||||
if (nodes.Count == 0)
|
|
||||||
return new List<TValue>();
|
|
||||||
if (getKey == null)
|
|
||||||
throw new ArgumentNullException(nameof(getKey));
|
|
||||||
if (getValue == null)
|
|
||||||
throw new ArgumentNullException(nameof(getValue));
|
|
||||||
solveTies = solveTies ?? Comparer<T>.Default;
|
|
||||||
List<TValue> result = new List<TValue>(nodes.Count);
|
|
||||||
HashSet<TDepend> allKeys = new HashSet<TDepend>(nodes.Count);
|
|
||||||
var noDependencies = new SortedDictionary<T, HashSet<TDepend>>(solveTies);
|
|
||||||
|
|
||||||
foreach (var node in nodes)
|
|
||||||
allKeys.Add(getKey(node));
|
|
||||||
var dependenciesByValues = nodes.ToDictionary(node => node,
|
|
||||||
node => new HashSet<TDepend>(dependsOn(node).Where(n => allKeys.Contains(n))));
|
|
||||||
foreach (var e in dependenciesByValues.Where(x => x.Value.Count == 0))
|
|
||||||
{
|
|
||||||
noDependencies.Add(e.Key, e.Value);
|
|
||||||
}
|
|
||||||
if (noDependencies.Count == 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Impossible to topologically sort a cyclic graph");
|
|
||||||
}
|
|
||||||
while (noDependencies.Count > 0)
|
|
||||||
{
|
|
||||||
var nodep = noDependencies.First();
|
|
||||||
noDependencies.Remove(nodep.Key);
|
|
||||||
dependenciesByValues.Remove(nodep.Key);
|
|
||||||
|
|
||||||
var elemKey = getKey(nodep.Key);
|
|
||||||
result.Add(getValue(nodep.Key));
|
|
||||||
foreach (var selem in dependenciesByValues)
|
|
||||||
{
|
|
||||||
if (selem.Value.Remove(elemKey) && selem.Value.Count == 0)
|
|
||||||
noDependencies.Add(selem.Key, selem.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dependenciesByValues.Count != 0)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Impossible to topologically sort a cyclic graph");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class ToPostgresMigrationStartupTask : IStartupTask
|
|
||||||
{
|
|
||||||
|
|
||||||
public ToPostgresMigrationStartupTask(
|
|
||||||
IConfiguration configuration,
|
|
||||||
IOptions<DataDirectories> datadirs,
|
|
||||||
ILogger<ToPostgresMigrationStartupTask> logger,
|
|
||||||
IWebHostEnvironment environment,
|
|
||||||
ApplicationDbContextFactory dbContextFactory)
|
|
||||||
{
|
|
||||||
Configuration = configuration;
|
|
||||||
Datadirs = datadirs;
|
|
||||||
Logger = logger;
|
|
||||||
Environment = environment;
|
|
||||||
DbContextFactory = dbContextFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
|
||||||
public IOptions<DataDirectories> Datadirs { get; }
|
|
||||||
public ILogger<ToPostgresMigrationStartupTask> Logger { get; }
|
|
||||||
public IWebHostEnvironment Environment { get; }
|
|
||||||
public ApplicationDbContextFactory DbContextFactory { get; }
|
|
||||||
public bool HasError { get; private set; }
|
|
||||||
|
|
||||||
public async Task ExecuteAsync(CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
var p = Configuration.GetOrDefault<string?>("POSTGRES", null);
|
|
||||||
var sqlite = Configuration.GetOrDefault<string?>("SQLITEFILE", null);
|
|
||||||
var mysql = Configuration.GetOrDefault<string?>("MYSQL", null);
|
|
||||||
|
|
||||||
string migratingFrom;
|
|
||||||
ApplicationDbContext otherContext;
|
|
||||||
if (string.IsNullOrEmpty(p))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!string.IsNullOrEmpty(sqlite))
|
|
||||||
{
|
|
||||||
migratingFrom = "SQLite";
|
|
||||||
sqlite = Datadirs.Value.ToDatadirFullPath(sqlite);
|
|
||||||
if (!File.Exists(sqlite))
|
|
||||||
return;
|
|
||||||
otherContext = new ApplicationDbContext(new DbContextOptionsBuilder<ApplicationDbContext>().UseSqlite("Data Source=" + sqlite, o => o.CommandTimeout(60 * 60 * 10)).Options);
|
|
||||||
}
|
|
||||||
else if (!string.IsNullOrEmpty(mysql))
|
|
||||||
{
|
|
||||||
migratingFrom = "MySQL";
|
|
||||||
otherContext = new ApplicationDbContext(new DbContextOptionsBuilder<ApplicationDbContext>().UseMySql(mysql, ServerVersion.AutoDetect(mysql), o => o.CommandTimeout(60 * 60 * 10)).Options);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await otherContext.Settings.FirstOrDefaultAsync();
|
|
||||||
}
|
|
||||||
catch (MySqlException ex) when (ex.SqlState == "42000") // DB doesn't exists
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (await otherContext.Settings.FirstOrDefaultAsync() == null)
|
|
||||||
return;
|
|
||||||
{
|
|
||||||
using var postgresContext = new ApplicationDbContext(new DbContextOptionsBuilder<ApplicationDbContext>().UseNpgsql(p, o =>
|
|
||||||
{
|
|
||||||
o.CommandTimeout(60 * 60 * 10);
|
|
||||||
o.SetPostgresVersion(12, 0);
|
|
||||||
}).Options);
|
|
||||||
string? state;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
state = await GetMigrationState(postgresContext);
|
|
||||||
if (state == "complete")
|
|
||||||
return;
|
|
||||||
if (state == null)
|
|
||||||
throw new ConfigException("This postgres database isn't created during a migration. Please use an empty database for postgres when migrating. If it's not a migration, remove --sqlitefile or --mysql settings.");
|
|
||||||
}
|
|
||||||
catch (NpgsqlException ex) when (ex.SqlState == PostgresErrorCodes.InvalidCatalogName || ex.SqlState == PostgresErrorCodes.UndefinedTable) // DB doesn't exists
|
|
||||||
{
|
|
||||||
await postgresContext.Database.MigrateAsync();
|
|
||||||
state = "pending";
|
|
||||||
await SetMigrationState(postgresContext, migratingFrom, "pending");
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.LogInformation($"Migrating from {migratingFrom} to Postgres...");
|
|
||||||
if (state == "pending")
|
|
||||||
{
|
|
||||||
Logger.LogInformation($"There is a unfinished migration in postgres... dropping all tables");
|
|
||||||
foreach (var t in postgresContext.Model.GetRelationalModel().Tables.OrderByTopology())
|
|
||||||
{
|
|
||||||
await postgresContext.Database.ExecuteSqlRawAsync($"DROP TABLE IF EXISTS \"{t.Name}\" CASCADE");
|
|
||||||
}
|
|
||||||
await postgresContext.Database.ExecuteSqlRawAsync($"DROP TABLE IF EXISTS \"__EFMigrationsHistory\" CASCADE");
|
|
||||||
await postgresContext.Database.MigrateAsync();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ConfigException("This database isn't created during a migration. Please use an empty database for postgres when migrating.");
|
|
||||||
}
|
|
||||||
await otherContext.Database.MigrateAsync();
|
|
||||||
|
|
||||||
await SetMigrationState(postgresContext, migratingFrom, "pending");
|
|
||||||
|
|
||||||
foreach (var t in postgresContext.Model.GetRelationalModel().Tables.OrderByTopology())
|
|
||||||
{
|
|
||||||
var typeMapping = t.EntityTypeMappings.Single();
|
|
||||||
var query = (IQueryable<object>)otherContext.GetType().GetMethod("Set", new Type[0])!.MakeGenericMethod(typeMapping.TypeBase.ClrType).Invoke(otherContext, null)!;
|
|
||||||
if (t.Name == "WebhookDeliveries" ||
|
|
||||||
t.Name == "InvoiceWebhookDeliveries" ||
|
|
||||||
t.Name == "StoreRoles")
|
|
||||||
continue;
|
|
||||||
Logger.LogInformation($"Migrating table: " + t.Name);
|
|
||||||
List<PropertyInfo> datetimeProperties = new List<PropertyInfo>();
|
|
||||||
foreach (var col in t.Columns)
|
|
||||||
if (col.PropertyMappings.Single().Property.ClrType == typeof(DateTime))
|
|
||||||
{
|
|
||||||
datetimeProperties.Add(col.PropertyMappings.Single().Property.PropertyInfo!);
|
|
||||||
}
|
|
||||||
List<PropertyInfo> datetimeoffsetProperties = new List<PropertyInfo>();
|
|
||||||
foreach (var col in t.Columns)
|
|
||||||
if (col.PropertyMappings.Single().Property.ClrType == typeof(DateTimeOffset))
|
|
||||||
{
|
|
||||||
datetimeoffsetProperties.Add(col.PropertyMappings.Single().Property.PropertyInfo!);
|
|
||||||
}
|
|
||||||
var rows = await query.ToListAsync();
|
|
||||||
foreach (var row in rows)
|
|
||||||
{
|
|
||||||
foreach (var prop in datetimeProperties)
|
|
||||||
{
|
|
||||||
var v = (DateTime)prop.GetValue(row)!;
|
|
||||||
if (v.Kind == DateTimeKind.Unspecified)
|
|
||||||
{
|
|
||||||
v = new DateTime(v.Ticks, DateTimeKind.Utc);
|
|
||||||
prop.SetValue(row, v);
|
|
||||||
}
|
|
||||||
else if (v.Kind == DateTimeKind.Local)
|
|
||||||
{
|
|
||||||
prop.SetValue(row, v.ToUniversalTime());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var prop in datetimeoffsetProperties)
|
|
||||||
{
|
|
||||||
var v = (DateTimeOffset)prop.GetValue(row)!;
|
|
||||||
if (v.Offset != TimeSpan.Zero)
|
|
||||||
{
|
|
||||||
prop.SetValue(row, v.ToOffset(TimeSpan.Zero));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
postgresContext.Entry(row).State = EntityState.Added;
|
|
||||||
}
|
|
||||||
await postgresContext.SaveChangesAsync();
|
|
||||||
postgresContext.ChangeTracker.Clear();
|
|
||||||
}
|
|
||||||
await postgresContext.SaveChangesAsync();
|
|
||||||
postgresContext.ChangeTracker.Clear();
|
|
||||||
await UpdateSequenceInvoiceSearch(postgresContext);
|
|
||||||
await SetMigrationState(postgresContext, migratingFrom, "complete");
|
|
||||||
}
|
|
||||||
otherContext.Dispose();
|
|
||||||
SqliteConnection.ClearAllPools();
|
|
||||||
MySqlConnection.ClearAllPools();
|
|
||||||
|
|
||||||
Logger.LogInformation($"Migration to postgres from {migratingFrom} successful");
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static async Task UpdateSequenceInvoiceSearch(ApplicationDbContext postgresContext)
|
|
||||||
{
|
|
||||||
await postgresContext.Database.ExecuteSqlRawAsync("SELECT SETVAL('\"InvoiceSearches_Id_seq\"', (SELECT max(\"Id\") FROM \"InvoiceSearches\"));");
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static async Task<string?> GetMigrationState(ApplicationDbContext postgresContext)
|
|
||||||
{
|
|
||||||
var o = (await postgresContext.Settings.FromSqlRaw("SELECT \"Id\", \"Value\" FROM \"Settings\" WHERE \"Id\"='MigrationData'").AsNoTracking().FirstOrDefaultAsync())?.Value;
|
|
||||||
if (o is null)
|
|
||||||
return null;
|
|
||||||
return JObject.Parse(o)["state"]?.Value<string>();
|
|
||||||
}
|
|
||||||
private static async Task SetMigrationState(ApplicationDbContext postgresContext, string migratingFrom, string state)
|
|
||||||
{
|
|
||||||
await postgresContext.Database.ExecuteSqlRawAsync(
|
|
||||||
"INSERT INTO \"Settings\" VALUES ('MigrationData', @p0::JSONB) ON CONFLICT (\"Id\") DO UPDATE SET \"Value\"=@p0::JSONB",
|
|
||||||
new[] { $"{{ \"from\": \"{migratingFrom}\", \"state\": \"{state}\" }}" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -33,8 +33,6 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||||
public IFormFile CssFile { get; set; }
|
public IFormFile CssFile { get; set; }
|
||||||
public string CssFileId { get; set; }
|
public string CssFileId { get; set; }
|
||||||
|
|
||||||
public bool CanDelete { get; set; }
|
|
||||||
|
|
||||||
public bool Archived { get; set; }
|
public bool Archived { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Allow anyone to create invoice")]
|
[Display(Name = "Allow anyone to create invoice")]
|
||||||
|
|
|
@ -335,8 +335,6 @@ namespace BTCPayServer.Services.Stores
|
||||||
public async Task CleanUnreachableStores()
|
public async Task CleanUnreachableStores()
|
||||||
{
|
{
|
||||||
await using var ctx = _ContextFactory.CreateContext();
|
await using var ctx = _ContextFactory.CreateContext();
|
||||||
if (!ctx.Database.SupportDropForeignKey())
|
|
||||||
return;
|
|
||||||
var events = new List<Events.StoreRemovedEvent>();
|
var events = new List<Events.StoreRemovedEvent>();
|
||||||
foreach (var store in await ctx.Stores.Include(data => data.UserStores)
|
foreach (var store in await ctx.Stores.Include(data => data.UserStores)
|
||||||
.ThenInclude(store => store.StoreRole).Where(s =>
|
.ThenInclude(store => store.StoreRole).Where(s =>
|
||||||
|
@ -368,8 +366,6 @@ namespace BTCPayServer.Services.Stores
|
||||||
private async Task DeleteStoreIfOrphan(string storeId)
|
private async Task DeleteStoreIfOrphan(string storeId)
|
||||||
{
|
{
|
||||||
await using var ctx = _ContextFactory.CreateContext();
|
await using var ctx = _ContextFactory.CreateContext();
|
||||||
if (ctx.Database.SupportDropForeignKey())
|
|
||||||
{
|
|
||||||
if (!await ctx.UserStore.Where(u => u.StoreDataId == storeId && u.StoreRole.Permissions.Contains(Policies.CanModifyStoreSettings)).AnyAsync())
|
if (!await ctx.UserStore.Where(u => u.StoreDataId == storeId && u.StoreRole.Permissions.Contains(Policies.CanModifyStoreSettings)).AnyAsync())
|
||||||
{
|
{
|
||||||
var store = await ctx.Stores.FindAsync(storeId);
|
var store = await ctx.Stores.FindAsync(storeId);
|
||||||
|
@ -381,7 +377,6 @@ namespace BTCPayServer.Services.Stores
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public async Task CreateStore(string ownerId, StoreData storeData, StoreRoleId? roleId = null)
|
public async Task CreateStore(string ownerId, StoreData storeData, StoreRoleId? roleId = null)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(storeData.Id))
|
if (!string.IsNullOrEmpty(storeData.Id))
|
||||||
|
@ -559,8 +554,6 @@ namespace BTCPayServer.Services.Stores
|
||||||
{
|
{
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
using var ctx = _ContextFactory.CreateContext();
|
using var ctx = _ContextFactory.CreateContext();
|
||||||
if (!ctx.Database.SupportDropForeignKey())
|
|
||||||
return false;
|
|
||||||
var store = await ctx.Stores.FindAsync(storeId);
|
var store = await ctx.Stores.FindAsync(storeId);
|
||||||
if (store == null)
|
if (store == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -641,12 +634,6 @@ retry:
|
||||||
{
|
{
|
||||||
return ex.InnerException is Npgsql.PostgresException postgres && postgres.SqlState == "40P01";
|
return ex.InnerException is Npgsql.PostgresException postgres && postgres.SqlState == "40P01";
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanDeleteStores()
|
|
||||||
{
|
|
||||||
using var ctx = _ContextFactory.CreateContext();
|
|
||||||
return ctx.Database.SupportDropForeignKey();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public record StoreRoleId
|
public record StoreRoleId
|
||||||
|
|
|
@ -55,7 +55,6 @@ namespace BTCPayServer.Services
|
||||||
public string? Type { get; set; }
|
public string? Type { get; set; }
|
||||||
public string[]? Ids { get; set; }
|
public string[]? Ids { get; set; }
|
||||||
public bool IncludeNeighbours { get; set; } = true;
|
public bool IncludeNeighbours { get; set; } = true;
|
||||||
public bool UseInefficientPath { get; set; }
|
|
||||||
|
|
||||||
public static IEnumerable<ObjectTypeId> Get(ReceivedCoin coin)
|
public static IEnumerable<ObjectTypeId> Get(ReceivedCoin coin)
|
||||||
{
|
{
|
||||||
|
@ -96,8 +95,6 @@ namespace BTCPayServer.Services
|
||||||
// pg_stat_statements output, making it impossible to analyze the performance impact of this query.
|
// pg_stat_statements output, making it impossible to analyze the performance impact of this query.
|
||||||
// On top of this, the entity version is doing 2 left join to satisfy the Include queries, resulting in n*m row returned for each transaction.
|
// On top of this, the entity version is doing 2 left join to satisfy the Include queries, resulting in n*m row returned for each transaction.
|
||||||
// n being the number of children, m the number of parents.
|
// n being the number of children, m the number of parents.
|
||||||
if (ctx.Database.IsNpgsql() && !queryObject.UseInefficientPath)
|
|
||||||
{
|
|
||||||
var connection = ctx.Database.GetDbConnection();
|
var connection = ctx.Database.GetDbConnection();
|
||||||
if (connection.State != System.Data.ConnectionState.Open)
|
if (connection.State != System.Data.ConnectionState.Open)
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
|
@ -211,37 +208,6 @@ namespace BTCPayServer.Services
|
||||||
}
|
}
|
||||||
return wosById;
|
return wosById;
|
||||||
}
|
}
|
||||||
else // Unefficient path
|
|
||||||
{
|
|
||||||
IQueryable<WalletObjectData> q;
|
|
||||||
if (queryObject.TypesIds is not null)
|
|
||||||
{
|
|
||||||
// Note this is problematic if the type contains '##', but I don't see how to do it properly with entity framework
|
|
||||||
var idTypes = queryObject.TypesIds.Select(o => $"{o.Type}##{o.Id}").ToArray();
|
|
||||||
q = ctx.WalletObjects
|
|
||||||
.Where(w => (queryObject.WalletId == null || w.WalletId == queryObject.WalletId.ToString()) && idTypes.Contains(w.Type + "##" + w.Id));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
q = ctx.WalletObjects
|
|
||||||
.Where(w => (queryObject.WalletId == null || w.WalletId == queryObject.WalletId.ToString()) && (queryObject.Type == null || w.Type == queryObject.Type) && (queryObject.Ids == null || queryObject.Ids.Contains(w.Id)));
|
|
||||||
}
|
|
||||||
if (queryObject.IncludeNeighbours)
|
|
||||||
{
|
|
||||||
q = q.Include(o => o.Bs).ThenInclude(o => o.B)
|
|
||||||
.Include(o => o.As).ThenInclude(o => o.A);
|
|
||||||
}
|
|
||||||
q = q.AsNoTracking();
|
|
||||||
|
|
||||||
var wosById = new Dictionary<WalletObjectId, WalletObjectData>();
|
|
||||||
foreach (var row in await q.ToListAsync())
|
|
||||||
{
|
|
||||||
var id = new WalletObjectId(WalletId.Parse(row.WalletId), row.Type, row.Id);
|
|
||||||
wosById.TryAdd(id, row);
|
|
||||||
}
|
|
||||||
return wosById;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|
||||||
public async Task<Dictionary<string, WalletTransactionInfo>> GetWalletTransactionsInfo(WalletId walletId,
|
public async Task<Dictionary<string, WalletTransactionInfo>> GetWalletTransactionsInfo(WalletId walletId,
|
||||||
|
|
|
@ -176,10 +176,7 @@
|
||||||
}
|
}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@if (Model.CanDelete)
|
|
||||||
{
|
|
||||||
<a id="DeleteStore" class="btn btn-outline-danger" asp-action="DeleteStore" asp-route-storeId="@Model.Id" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="The store <strong>@Html.Encode(Model.StoreName)</strong> will be permanently deleted. This action will also delete all invoices, apps and data associated with the store." data-confirm-input="DELETE">Delete this store</a>
|
<a id="DeleteStore" class="btn btn-outline-danger" asp-action="DeleteStore" asp-route-storeId="@Model.Id" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="The store <strong>@Html.Encode(Model.StoreName)</strong> will be permanently deleted. This action will also delete all invoices, apps and data associated with the store." data-confirm-input="DELETE">Delete this store</a>
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue