Fix db and fix endpoints

This commit is contained in:
2025-08-05 22:30:18 +07:00
parent 2dcbcc3ef2
commit 36529ae403
36 changed files with 5073 additions and 245 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class UniqueUsername : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Users_Name",
table: "Users",
column: "Name",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Users_Name",
table: "Users");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AccountUpdate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "UserId",
table: "Accounts",
type: "integer",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "integer",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Key",
table: "Accounts",
type: "character varying(500)",
maxLength: 500,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "character varying(500)",
oldMaxLength: 500,
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "UserId",
table: "Accounts",
type: "integer",
nullable: true,
oldClrType: typeof(int),
oldType: "integer");
migrationBuilder.AlterColumn<string>(
name: "Key",
table: "Accounts",
type: "character varying(500)",
maxLength: 500,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(500)",
oldMaxLength: 500);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,425 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class UserKeys : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Signals_Identifier_Date_UserName",
table: "Signals");
migrationBuilder.DropIndex(
name: "IX_Signals_UserName",
table: "Signals");
migrationBuilder.DropIndex(
name: "IX_Signals_UserName_Date",
table: "Signals");
migrationBuilder.DropIndex(
name: "IX_Scenarios_UserName",
table: "Scenarios");
migrationBuilder.DropIndex(
name: "IX_Scenarios_UserName_Name",
table: "Scenarios");
migrationBuilder.DropIndex(
name: "IX_Positions_UserName",
table: "Positions");
migrationBuilder.DropIndex(
name: "IX_Positions_UserName_Identifier",
table: "Positions");
migrationBuilder.DropIndex(
name: "IX_Indicators_UserName",
table: "Indicators");
migrationBuilder.DropIndex(
name: "IX_Indicators_UserName_Name",
table: "Indicators");
migrationBuilder.DropIndex(
name: "IX_BundleBacktestRequests_UserName",
table: "BundleBacktestRequests");
migrationBuilder.DropIndex(
name: "IX_BundleBacktestRequests_UserName_CreatedAt",
table: "BundleBacktestRequests");
migrationBuilder.DropIndex(
name: "IX_Backtests_UserName",
table: "Backtests");
migrationBuilder.DropIndex(
name: "IX_Backtests_UserName_Score",
table: "Backtests");
migrationBuilder.DropColumn(
name: "UserName",
table: "Signals");
migrationBuilder.DropColumn(
name: "UserName",
table: "Scenarios");
migrationBuilder.DropColumn(
name: "UserName",
table: "Positions");
migrationBuilder.DropColumn(
name: "UserName",
table: "Indicators");
migrationBuilder.DropColumn(
name: "UserName",
table: "BundleBacktestRequests");
migrationBuilder.DropColumn(
name: "UserName",
table: "Backtests");
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "Signals",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "Scenarios",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "Positions",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "Indicators",
type: "integer",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "Backtests",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Signals_Identifier_Date_UserId",
table: "Signals",
columns: new[] { "Identifier", "Date", "UserId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Signals_UserId",
table: "Signals",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Signals_UserId_Date",
table: "Signals",
columns: new[] { "UserId", "Date" });
migrationBuilder.CreateIndex(
name: "IX_Scenarios_UserId",
table: "Scenarios",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Scenarios_UserId_Name",
table: "Scenarios",
columns: new[] { "UserId", "Name" });
migrationBuilder.CreateIndex(
name: "IX_Positions_UserId",
table: "Positions",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Positions_UserId_Identifier",
table: "Positions",
columns: new[] { "UserId", "Identifier" });
migrationBuilder.CreateIndex(
name: "IX_Indicators_UserId",
table: "Indicators",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Indicators_UserId_Name",
table: "Indicators",
columns: new[] { "UserId", "Name" });
migrationBuilder.CreateIndex(
name: "IX_BundleBacktestRequests_UserId_CreatedAt",
table: "BundleBacktestRequests",
columns: new[] { "UserId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_Backtests_UserId",
table: "Backtests",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Backtests_UserId_Score",
table: "Backtests",
columns: new[] { "UserId", "Score" });
migrationBuilder.AddForeignKey(
name: "FK_Backtests_Users_UserId",
table: "Backtests",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Indicators_Users_UserId",
table: "Indicators",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Positions_Users_UserId",
table: "Positions",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Scenarios_Users_UserId",
table: "Scenarios",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
migrationBuilder.AddForeignKey(
name: "FK_Signals_Users_UserId",
table: "Signals",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Backtests_Users_UserId",
table: "Backtests");
migrationBuilder.DropForeignKey(
name: "FK_Indicators_Users_UserId",
table: "Indicators");
migrationBuilder.DropForeignKey(
name: "FK_Positions_Users_UserId",
table: "Positions");
migrationBuilder.DropForeignKey(
name: "FK_Scenarios_Users_UserId",
table: "Scenarios");
migrationBuilder.DropForeignKey(
name: "FK_Signals_Users_UserId",
table: "Signals");
migrationBuilder.DropIndex(
name: "IX_Signals_Identifier_Date_UserId",
table: "Signals");
migrationBuilder.DropIndex(
name: "IX_Signals_UserId",
table: "Signals");
migrationBuilder.DropIndex(
name: "IX_Signals_UserId_Date",
table: "Signals");
migrationBuilder.DropIndex(
name: "IX_Scenarios_UserId",
table: "Scenarios");
migrationBuilder.DropIndex(
name: "IX_Scenarios_UserId_Name",
table: "Scenarios");
migrationBuilder.DropIndex(
name: "IX_Positions_UserId",
table: "Positions");
migrationBuilder.DropIndex(
name: "IX_Positions_UserId_Identifier",
table: "Positions");
migrationBuilder.DropIndex(
name: "IX_Indicators_UserId",
table: "Indicators");
migrationBuilder.DropIndex(
name: "IX_Indicators_UserId_Name",
table: "Indicators");
migrationBuilder.DropIndex(
name: "IX_BundleBacktestRequests_UserId_CreatedAt",
table: "BundleBacktestRequests");
migrationBuilder.DropIndex(
name: "IX_Backtests_UserId",
table: "Backtests");
migrationBuilder.DropIndex(
name: "IX_Backtests_UserId_Score",
table: "Backtests");
migrationBuilder.DropColumn(
name: "UserId",
table: "Signals");
migrationBuilder.DropColumn(
name: "UserId",
table: "Scenarios");
migrationBuilder.DropColumn(
name: "UserId",
table: "Positions");
migrationBuilder.DropColumn(
name: "UserId",
table: "Indicators");
migrationBuilder.DropColumn(
name: "UserId",
table: "Backtests");
migrationBuilder.AddColumn<string>(
name: "UserName",
table: "Signals",
type: "character varying(255)",
maxLength: 255,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "UserName",
table: "Scenarios",
type: "character varying(255)",
maxLength: 255,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "UserName",
table: "Positions",
type: "character varying(255)",
maxLength: 255,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "UserName",
table: "Indicators",
type: "character varying(255)",
maxLength: 255,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "UserName",
table: "BundleBacktestRequests",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "UserName",
table: "Backtests",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "");
migrationBuilder.CreateIndex(
name: "IX_Signals_Identifier_Date_UserName",
table: "Signals",
columns: new[] { "Identifier", "Date", "UserName" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Signals_UserName",
table: "Signals",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_Signals_UserName_Date",
table: "Signals",
columns: new[] { "UserName", "Date" });
migrationBuilder.CreateIndex(
name: "IX_Scenarios_UserName",
table: "Scenarios",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_Scenarios_UserName_Name",
table: "Scenarios",
columns: new[] { "UserName", "Name" });
migrationBuilder.CreateIndex(
name: "IX_Positions_UserName",
table: "Positions",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_Positions_UserName_Identifier",
table: "Positions",
columns: new[] { "UserName", "Identifier" });
migrationBuilder.CreateIndex(
name: "IX_Indicators_UserName",
table: "Indicators",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_Indicators_UserName_Name",
table: "Indicators",
columns: new[] { "UserName", "Name" });
migrationBuilder.CreateIndex(
name: "IX_BundleBacktestRequests_UserName",
table: "BundleBacktestRequests",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_BundleBacktestRequests_UserName_CreatedAt",
table: "BundleBacktestRequests",
columns: new[] { "UserName", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_Backtests_UserName",
table: "Backtests",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_Backtests_UserName_Score",
table: "Backtests",
columns: new[] { "UserName", "Score" });
}
}
}

View File

@@ -35,6 +35,7 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasColumnType("text");
b.Property<string>("Key")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("character varying(500)");
@@ -51,7 +52,7 @@ namespace Managing.Infrastructure.Databases.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
@@ -192,10 +193,8 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<int>("WinRate")
.HasColumnType("integer");
@@ -209,11 +208,11 @@ namespace Managing.Infrastructure.Databases.Migrations
b.HasIndex("Score");
b.HasIndex("UserName");
b.HasIndex("UserId");
b.HasIndex("RequestId", "Score");
b.HasIndex("UserName", "Score");
b.HasIndex("UserId", "Score");
b.ToTable("Backtests");
});
@@ -347,11 +346,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<int?>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.HasKey("Id");
b.HasIndex("RequestId")
@@ -361,9 +355,7 @@ namespace Managing.Infrastructure.Databases.Migrations
b.HasIndex("UserId");
b.HasIndex("UserName");
b.HasIndex("UserName", "CreatedAt");
b.HasIndex("UserId", "CreatedAt");
b.ToTable("BundleBacktestRequests");
});
@@ -593,15 +585,14 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int?>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserName");
b.HasIndex("UserId");
b.HasIndex("UserName", "Name");
b.HasIndex("UserId", "Name");
b.ToTable("Indicators");
});
@@ -715,9 +706,8 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int?>("UserId")
.HasColumnType("integer");
b.HasKey("Identifier");
@@ -736,9 +726,9 @@ namespace Managing.Infrastructure.Databases.Migrations
b.HasIndex("TakeProfit2TradeId");
b.HasIndex("UserName");
b.HasIndex("UserId");
b.HasIndex("UserName", "Identifier");
b.HasIndex("UserId", "Identifier");
b.ToTable("Positions");
});
@@ -765,15 +755,14 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserName");
b.HasIndex("UserId");
b.HasIndex("UserName", "Name");
b.HasIndex("UserId", "Name");
b.ToTable("Scenarios");
});
@@ -863,9 +852,8 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int?>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
@@ -877,11 +865,11 @@ namespace Managing.Infrastructure.Databases.Migrations
b.HasIndex("Ticker");
b.HasIndex("UserName");
b.HasIndex("UserId");
b.HasIndex("UserName", "Date");
b.HasIndex("UserId", "Date");
b.HasIndex("Identifier", "Date", "UserName")
b.HasIndex("Identifier", "Date", "UserId")
.IsUnique();
b.ToTable("Signals");
@@ -1213,6 +1201,9 @@ namespace Managing.Infrastructure.Databases.Migrations
b.HasKey("Id");
b.HasIndex("Name")
.IsUnique();
b.ToTable("Users");
});
@@ -1256,7 +1247,8 @@ namespace Managing.Infrastructure.Databases.Migrations
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});
@@ -1272,6 +1264,17 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BacktestEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
@@ -1303,6 +1306,16 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.IndicatorEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.MoneyManagementEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
@@ -1335,6 +1348,11 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasForeignKey("TakeProfit2TradeId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("OpenTrade");
b.Navigation("StopLossTrade");
@@ -1342,6 +1360,19 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("TakeProfit1Trade");
b.Navigation("TakeProfit2Trade");
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.ScenarioEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.ScenarioIndicatorEntity", b =>
@@ -1363,6 +1394,16 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("Scenario");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.SignalEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.IndicatorEntity", b =>
{
b.Navigation("ScenarioIndicators");