diff --git a/swappy-bot/EntityFramework/SwapState.cs b/swappy-bot/EntityFramework/SwapState.cs index f08c5c8..1530893 100644 --- a/swappy-bot/EntityFramework/SwapState.cs +++ b/swappy-bot/EntityFramework/SwapState.cs @@ -56,17 +56,17 @@ public override void Configure(EntityTypeBuilder builder) builder.Property(x => x.AssetFrom).IsRequired(false).HasMaxLength(10); builder.Property(x => x.AssetTo).IsRequired(false).HasMaxLength(10); - builder.Property(x => x.Amount).IsRequired(false); + builder.Property(x => x.Amount).IsRequired(false).HasPrecision(27, 18); builder.Property(x => x.DestinationAddress).IsRequired(false).HasMaxLength(100); builder.Property(x => x.QuoteTime).IsRequired(false); builder.HasIndex(x => x.QuoteTime); - builder.Property(x => x.QuoteDeposit).IsRequired(false); - builder.Property(x => x.QuoteReceive).IsRequired(false); + builder.Property(x => x.QuoteDeposit).IsRequired(false).HasPrecision(27, 18); + builder.Property(x => x.QuoteReceive).IsRequired(false).HasPrecision(27, 18); builder.Property(x => x.QuoteRate).IsRequired(false).HasMaxLength(200); - builder.Property(x => x.QuotePlatformFee).IsRequired(false); - builder.Property(x => x.QuoteChainflipFee).IsRequired(false); + builder.Property(x => x.QuotePlatformFee).IsRequired(false).HasPrecision(27, 18); + builder.Property(x => x.QuoteChainflipFee).IsRequired(false).HasPrecision(27, 18); builder.Property(x => x.SwapAccepted).IsRequired(false); builder.HasIndex(x => x.SwapAccepted); diff --git a/swappy-bot/Migrations/20250128204642_FixPrecisions.Designer.cs b/swappy-bot/Migrations/20250128204642_FixPrecisions.Designer.cs new file mode 100644 index 0000000..b4ddabc --- /dev/null +++ b/swappy-bot/Migrations/20250128204642_FixPrecisions.Designer.cs @@ -0,0 +1,143 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SwappyBot.EntityFramework; + +#nullable disable + +namespace SwappyBot.Migrations +{ + [DbContext(typeof(BotContext))] + [Migration("20250128204642_FixPrecisions")] + partial class FixPrecisions + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SwappyBot.EntityFramework.SwapState", b => + { + b.Property("StateId") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("stateid"); + + b.Property("Amount") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") + .HasColumnName("amount"); + + b.Property("AnnouncementIds") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)") + .HasColumnName("announcementids"); + + b.Property("AssetFrom") + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("assetfrom"); + + b.Property("AssetTo") + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("assetto"); + + b.Property("DepositAddress") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("depositaddress"); + + b.Property("DepositChannel") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("depositchannel"); + + b.Property("DepositGenerated") + .HasColumnType("timestamp with time zone") + .HasColumnName("depositgenerated"); + + b.Property("DestinationAddress") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("destinationaddress"); + + b.Property("QuoteChainflipFee") + .HasColumnType("numeric") + .HasColumnName("quotechainflipfee"); + + b.Property("QuoteDeposit") + .HasColumnType("numeric") + .HasColumnName("quotedeposit"); + + b.Property("QuotePlatformFee") + .HasColumnType("numeric") + .HasColumnName("quoteplatformfee"); + + b.Property("QuoteRate") + .HasMaxLength(200) + .HasColumnType("character varying(200)") + .HasColumnName("quoterate"); + + b.Property("QuoteReceive") + .HasColumnType("numeric") + .HasColumnName("quotereceive"); + + b.Property("QuoteTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("quotetime"); + + b.Property("Replied") + .HasColumnType("boolean") + .HasColumnName("replied"); + + b.Property("SwapAccepted") + .HasColumnType("timestamp with time zone") + .HasColumnName("swapaccepted"); + + b.Property("SwapCancelled") + .HasColumnType("timestamp with time zone") + .HasColumnName("swapcancelled"); + + b.Property("SwapStarted") + .HasColumnType("timestamp with time zone") + .HasColumnName("swapstarted"); + + b.Property("SwapStatus") + .HasMaxLength(10000) + .HasColumnType("character varying(10000)") + .HasColumnName("swapstatus"); + + b.HasKey("StateId") + .HasName("pk_swap_state"); + + b.HasIndex("DepositGenerated") + .HasDatabaseName("ix_swap_state_depositgenerated"); + + b.HasIndex("QuoteTime") + .HasDatabaseName("ix_swap_state_quotetime"); + + b.HasIndex("SwapAccepted") + .HasDatabaseName("ix_swap_state_swapaccepted"); + + b.HasIndex("SwapCancelled") + .HasDatabaseName("ix_swap_state_swapcancelled"); + + b.HasIndex("SwapStarted") + .HasDatabaseName("ix_swap_state_swapstarted"); + + b.ToTable("swap_state", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/swappy-bot/Migrations/20250128204642_FixPrecisions.cs b/swappy-bot/Migrations/20250128204642_FixPrecisions.cs new file mode 100644 index 0000000..6032b37 --- /dev/null +++ b/swappy-bot/Migrations/20250128204642_FixPrecisions.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SwappyBot.Migrations +{ + /// + public partial class FixPrecisions : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "amount", + table: "swap_state", + type: "numeric(27,18)", + precision: 27, + scale: 18, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "amount", + table: "swap_state", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(27,18)", + oldPrecision: 27, + oldScale: 18, + oldNullable: true); + } + } +} diff --git a/swappy-bot/Migrations/20250128204729_FixAllPrecisions.Designer.cs b/swappy-bot/Migrations/20250128204729_FixAllPrecisions.Designer.cs new file mode 100644 index 0000000..71cf720 --- /dev/null +++ b/swappy-bot/Migrations/20250128204729_FixAllPrecisions.Designer.cs @@ -0,0 +1,147 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using SwappyBot.EntityFramework; + +#nullable disable + +namespace SwappyBot.Migrations +{ + [DbContext(typeof(BotContext))] + [Migration("20250128204729_FixAllPrecisions")] + partial class FixAllPrecisions + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("SwappyBot.EntityFramework.SwapState", b => + { + b.Property("StateId") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("stateid"); + + b.Property("Amount") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") + .HasColumnName("amount"); + + b.Property("AnnouncementIds") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)") + .HasColumnName("announcementids"); + + b.Property("AssetFrom") + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("assetfrom"); + + b.Property("AssetTo") + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("assetto"); + + b.Property("DepositAddress") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("depositaddress"); + + b.Property("DepositChannel") + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("depositchannel"); + + b.Property("DepositGenerated") + .HasColumnType("timestamp with time zone") + .HasColumnName("depositgenerated"); + + b.Property("DestinationAddress") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("destinationaddress"); + + b.Property("QuoteChainflipFee") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") + .HasColumnName("quotechainflipfee"); + + b.Property("QuoteDeposit") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") + .HasColumnName("quotedeposit"); + + b.Property("QuotePlatformFee") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") + .HasColumnName("quoteplatformfee"); + + b.Property("QuoteRate") + .HasMaxLength(200) + .HasColumnType("character varying(200)") + .HasColumnName("quoterate"); + + b.Property("QuoteReceive") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") + .HasColumnName("quotereceive"); + + b.Property("QuoteTime") + .HasColumnType("timestamp with time zone") + .HasColumnName("quotetime"); + + b.Property("Replied") + .HasColumnType("boolean") + .HasColumnName("replied"); + + b.Property("SwapAccepted") + .HasColumnType("timestamp with time zone") + .HasColumnName("swapaccepted"); + + b.Property("SwapCancelled") + .HasColumnType("timestamp with time zone") + .HasColumnName("swapcancelled"); + + b.Property("SwapStarted") + .HasColumnType("timestamp with time zone") + .HasColumnName("swapstarted"); + + b.Property("SwapStatus") + .HasMaxLength(10000) + .HasColumnType("character varying(10000)") + .HasColumnName("swapstatus"); + + b.HasKey("StateId") + .HasName("pk_swap_state"); + + b.HasIndex("DepositGenerated") + .HasDatabaseName("ix_swap_state_depositgenerated"); + + b.HasIndex("QuoteTime") + .HasDatabaseName("ix_swap_state_quotetime"); + + b.HasIndex("SwapAccepted") + .HasDatabaseName("ix_swap_state_swapaccepted"); + + b.HasIndex("SwapCancelled") + .HasDatabaseName("ix_swap_state_swapcancelled"); + + b.HasIndex("SwapStarted") + .HasDatabaseName("ix_swap_state_swapstarted"); + + b.ToTable("swap_state", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/swappy-bot/Migrations/20250128204729_FixAllPrecisions.cs b/swappy-bot/Migrations/20250128204729_FixAllPrecisions.cs new file mode 100644 index 0000000..3e0e805 --- /dev/null +++ b/swappy-bot/Migrations/20250128204729_FixAllPrecisions.cs @@ -0,0 +1,106 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SwappyBot.Migrations +{ + /// + public partial class FixAllPrecisions : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "quotereceive", + table: "swap_state", + type: "numeric(27,18)", + precision: 27, + scale: 18, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "quoteplatformfee", + table: "swap_state", + type: "numeric(27,18)", + precision: 27, + scale: 18, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "quotedeposit", + table: "swap_state", + type: "numeric(27,18)", + precision: 27, + scale: 18, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "quotechainflipfee", + table: "swap_state", + type: "numeric(27,18)", + precision: 27, + scale: 18, + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "quotereceive", + table: "swap_state", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(27,18)", + oldPrecision: 27, + oldScale: 18, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "quoteplatformfee", + table: "swap_state", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(27,18)", + oldPrecision: 27, + oldScale: 18, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "quotedeposit", + table: "swap_state", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(27,18)", + oldPrecision: 27, + oldScale: 18, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "quotechainflipfee", + table: "swap_state", + type: "numeric", + nullable: true, + oldClrType: typeof(decimal), + oldType: "numeric(27,18)", + oldPrecision: 27, + oldScale: 18, + oldNullable: true); + } + } +} diff --git a/swappy-bot/Migrations/BotContextModelSnapshot.cs b/swappy-bot/Migrations/BotContextModelSnapshot.cs index 0810d56..cfea239 100644 --- a/swappy-bot/Migrations/BotContextModelSnapshot.cs +++ b/swappy-bot/Migrations/BotContextModelSnapshot.cs @@ -30,7 +30,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnName("stateid"); b.Property("Amount") - .HasColumnType("numeric") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") .HasColumnName("amount"); b.Property("AnnouncementIds") @@ -68,15 +69,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnName("destinationaddress"); b.Property("QuoteChainflipFee") - .HasColumnType("numeric") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") .HasColumnName("quotechainflipfee"); b.Property("QuoteDeposit") - .HasColumnType("numeric") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") .HasColumnName("quotedeposit"); b.Property("QuotePlatformFee") - .HasColumnType("numeric") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") .HasColumnName("quoteplatformfee"); b.Property("QuoteRate") @@ -85,7 +89,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnName("quoterate"); b.Property("QuoteReceive") - .HasColumnType("numeric") + .HasPrecision(27, 18) + .HasColumnType("numeric(27,18)") .HasColumnName("quotereceive"); b.Property("QuoteTime")