Topup functions

This commit is contained in:
2023-07-04 14:11:53 +01:00
parent 013008dcf9
commit 00c918b1f6
17 changed files with 6519 additions and 12 deletions

View File

@ -0,0 +1,113 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NostrStreamer.Database;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace NostrStreamer.Migrations
{
[DbContext(typeof(StreamerContext))]
[Migration("20230704123736_PaymentSetup")]
partial class PaymentSetup
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("NostrStreamer.Database.Payment", b =>
{
b.Property<string>("PaymentHash")
.HasColumnType("text");
b.Property<decimal>("Amount")
.HasColumnType("numeric(20,0)");
b.Property<DateTime>("Created")
.HasColumnType("timestamp with time zone");
b.Property<string>("Invoice")
.IsRequired()
.HasColumnType("text");
b.Property<bool>("IsPaid")
.HasColumnType("boolean");
b.Property<string>("PubKey")
.IsRequired()
.HasColumnType("text");
b.HasKey("PaymentHash");
b.HasIndex("PubKey");
b.ToTable("Payments");
});
modelBuilder.Entity("NostrStreamer.Database.User", b =>
{
b.Property<string>("PubKey")
.HasColumnType("text");
b.Property<long>("Balance")
.HasColumnType("bigint");
b.Property<string>("Event")
.HasColumnType("text");
b.Property<string>("Image")
.HasColumnType("text");
b.Property<string>("StreamKey")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Summary")
.HasColumnType("text");
b.Property<string>("Tags")
.HasColumnType("text");
b.Property<string>("Title")
.HasColumnType("text");
b.Property<uint>("Version")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.HasKey("PubKey");
b.ToTable("Users");
});
modelBuilder.Entity("NostrStreamer.Database.Payment", b =>
{
b.HasOne("NostrStreamer.Database.User", "User")
.WithMany("Payments")
.HasForeignKey("PubKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("NostrStreamer.Database.User", b =>
{
b.Navigation("Payments");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,103 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NostrStreamer.Migrations
{
/// <inheritdoc />
public partial class PaymentSetup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Payments",
table: "Payments");
migrationBuilder.AddColumn<uint>(
name: "xmin",
table: "Users",
type: "xid",
rowVersion: true,
nullable: false,
defaultValue: 0u);
migrationBuilder.AddColumn<string>(
name: "PaymentHash",
table: "Payments",
type: "text",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<decimal>(
name: "Amount",
table: "Payments",
type: "numeric(20,0)",
nullable: false,
defaultValue: 0m);
migrationBuilder.AddColumn<DateTime>(
name: "Created",
table: "Payments",
type: "timestamp with time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddPrimaryKey(
name: "PK_Payments",
table: "Payments",
column: "PaymentHash");
migrationBuilder.CreateIndex(
name: "IX_Payments_PubKey",
table: "Payments",
column: "PubKey");
migrationBuilder.AddForeignKey(
name: "FK_Payments_Users_PubKey",
table: "Payments",
column: "PubKey",
principalTable: "Users",
principalColumn: "PubKey",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Payments_Users_PubKey",
table: "Payments");
migrationBuilder.DropPrimaryKey(
name: "PK_Payments",
table: "Payments");
migrationBuilder.DropIndex(
name: "IX_Payments_PubKey",
table: "Payments");
migrationBuilder.DropColumn(
name: "xmin",
table: "Users");
migrationBuilder.DropColumn(
name: "PaymentHash",
table: "Payments");
migrationBuilder.DropColumn(
name: "Amount",
table: "Payments");
migrationBuilder.DropColumn(
name: "Created",
table: "Payments");
migrationBuilder.AddPrimaryKey(
name: "PK_Payments",
table: "Payments",
column: "PubKey");
}
}
}

View File

@ -1,4 +1,5 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@ -23,9 +24,15 @@ namespace NostrStreamer.Migrations
modelBuilder.Entity("NostrStreamer.Database.Payment", b =>
{
b.Property<string>("PubKey")
b.Property<string>("PaymentHash")
.HasColumnType("text");
b.Property<decimal>("Amount")
.HasColumnType("numeric(20,0)");
b.Property<DateTime>("Created")
.HasColumnType("timestamp with time zone");
b.Property<string>("Invoice")
.IsRequired()
.HasColumnType("text");
@ -33,7 +40,13 @@ namespace NostrStreamer.Migrations
b.Property<bool>("IsPaid")
.HasColumnType("boolean");
b.HasKey("PubKey");
b.Property<string>("PubKey")
.IsRequired()
.HasColumnType("text");
b.HasKey("PaymentHash");
b.HasIndex("PubKey");
b.ToTable("Payments");
});
@ -65,10 +78,32 @@ namespace NostrStreamer.Migrations
b.Property<string>("Title")
.HasColumnType("text");
b.Property<uint>("Version")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.HasKey("PubKey");
b.ToTable("Users");
});
modelBuilder.Entity("NostrStreamer.Database.Payment", b =>
{
b.HasOne("NostrStreamer.Database.User", "User")
.WithMany("Payments")
.HasForeignKey("PubKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("NostrStreamer.Database.User", b =>
{
b.Navigation("Payments");
});
#pragma warning restore 612, 618
}
}