mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-30 11:24:23 +01:00
Store Settings feature with own table (#3851)
* Store Settings feature with own table * fix test * Include the store settings to StoreRepository, remove caching stuff Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
28
BTCPayServer.Data/Data/StoreSettingData.cs
Normal file
28
BTCPayServer.Data/Data/StoreSettingData.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace BTCPayServer.Data;
|
||||
|
||||
public class StoreSettingData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string StoreId { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
public StoreData Store { get; set; }
|
||||
|
||||
public static void OnModelCreating(ModelBuilder builder, DatabaseFacade databaseFacade)
|
||||
{
|
||||
builder.Entity<StoreSettingData>().HasKey(data => new { data.StoreId, data.Name });
|
||||
builder.Entity<StoreSettingData>()
|
||||
.HasOne(o => o.Store)
|
||||
.WithMany(o => o.Settings).OnDelete(DeleteBehavior.Cascade);
|
||||
if (databaseFacade.IsNpgsql())
|
||||
{
|
||||
builder.Entity<StoreSettingData>()
|
||||
.Property(o => o.Value)
|
||||
.HasColumnType("JSONB");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user