V2 upgrade

This commit is contained in:
2023-07-25 17:45:44 +01:00
parent dae8f99d33
commit 3c16cb51d4
41 changed files with 2056 additions and 427 deletions

View File

@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class IngestEndpointConfiguration : IEntityTypeConfiguration<IngestEndpoint>
{
public void Configure(EntityTypeBuilder<IngestEndpoint> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.Name)
.IsRequired();
builder.Property(a => a.App)
.IsRequired();
builder.Property(a => a.Forward)
.IsRequired();
builder.Property(a => a.Cost)
.IsRequired();
builder.Property(a => a.Capabilities)
.IsRequired();
builder.HasIndex(a => a.App)
.IsUnique();
}
}

View File

@ -19,7 +19,11 @@ public class PaymentsConfiguration : IEntityTypeConfiguration<Payment>
builder.Property(a => a.Created)
.IsRequired();
builder.Property(a => a.Nostr);
builder.Property(a => a.Type)
.IsRequired();
builder.HasOne(a => a.User)
.WithMany(a => a.Payments)
.HasForeignKey(a => a.PubKey);

View File

@ -11,7 +11,6 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
builder.Property(a => a.StreamKey)
.IsRequired();
builder.Property(a => a.Event);
builder.Property(a => a.Balance)
.IsRequired();

View File

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class UserStreamConfiguration : IEntityTypeConfiguration<UserStream>
{
public void Configure(EntityTypeBuilder<UserStream> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.ClientId)
.IsRequired();
builder.Property(a => a.Starts)
.IsRequired();
builder.Property(a => a.Ends);
builder.Property(a => a.State)
.IsRequired();
builder.Property(a => a.Event)
.IsRequired();
builder.Property(a => a.Recording);
builder.HasOne(a => a.Endpoint)
.WithMany()
.HasForeignKey(a => a.EndpointId);
builder.HasOne(a => a.User)
.WithMany(a => a.Streams)
.HasForeignKey(a => a.PubKey);
}
}

View File

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class UserStreamGuestConfiguration : IEntityTypeConfiguration<UserStreamGuest>
{
public void Configure(EntityTypeBuilder<UserStreamGuest> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.PubKey)
.IsRequired();
builder.Property(a => a.Sig);
builder.Property(a => a.Relay);
builder.Property(a => a.Role);
builder.Property(a => a.ZapSplit);
builder.HasOne(a => a.Stream)
.WithMany(a => a.Guests)
.HasForeignKey(a => a.StreamId);
builder.HasIndex(a => new {a.StreamId, a.PubKey})
.IsUnique();
}
}