Files
GreenHomeBack/src/GreenHome.Infrastructure/Data/Migrations/Migrations/20251216152746_AddDailyReportsTable.cs

71 lines
3.1 KiB
C#

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");
}
}
}