refactor: reorganize Infrastructure layer into folder structure with DI

This commit is contained in:
2026-06-01 18:15:58 +03:30
parent 775ae0d9b4
commit 9fe575ae07
55 changed files with 2960 additions and 3031 deletions

View File

@@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreenHome.Infrastructure.Data.Migrations
{
/// <inheritdoc />
public partial class AddDailyReportsTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DailyReports",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DeviceId = table.Column<int>(type: "int", nullable: false),
PersianDate = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
PersianYear = table.Column<int>(type: "int", nullable: false),
PersianMonth = table.Column<int>(type: "int", nullable: false),
PersianDay = table.Column<int>(type: "int", nullable: false),
Analysis = table.Column<string>(type: "nvarchar(max)", nullable: false),
RecordCount = table.Column<int>(type: "int", nullable: false),
SampledRecordCount = table.Column<int>(type: "int", nullable: false),
PromptTokens = table.Column<int>(type: "int", nullable: false),
CompletionTokens = table.Column<int>(type: "int", nullable: false),
TotalTokens = table.Column<int>(type: "int", nullable: false),
Model = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ResponseTimeMs = table.Column<long>(type: "bigint", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DailyReports", x => x.Id);
table.ForeignKey(
name: "FK_DailyReports_Devices_DeviceId",
column: x => x.DeviceId,
principalTable: "Devices",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_DailyReports_CreatedAt",
table: "DailyReports",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_DailyReports_DeviceId_PersianDate",
table: "DailyReports",
columns: new[] { "DeviceId", "PersianDate" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DailyReports_DeviceId_PersianYear_PersianMonth",
table: "DailyReports",
columns: new[] { "DeviceId", "PersianYear", "PersianMonth" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "DailyReports");
}
}
}