226 lines
11 KiB
C#
226 lines
11 KiB
C#
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||
|
|
|
||
|
|
#nullable disable
|
||
|
|
|
||
|
|
namespace HardwarePerformance.Infrastructure.Data.Migrations
|
||
|
|
{
|
||
|
|
/// <inheritdoc />
|
||
|
|
public partial class InitialCreate : Migration
|
||
|
|
{
|
||
|
|
/// <inheritdoc />
|
||
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||
|
|
{
|
||
|
|
migrationBuilder.CreateTable(
|
||
|
|
name: "Categories",
|
||
|
|
columns: table => new
|
||
|
|
{
|
||
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
||
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||
|
|
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||
|
|
Description = table.Column<string>(type: "text", nullable: true),
|
||
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||
|
|
},
|
||
|
|
constraints: table =>
|
||
|
|
{
|
||
|
|
table.PrimaryKey("PK_Categories", x => x.Id);
|
||
|
|
});
|
||
|
|
|
||
|
|
migrationBuilder.CreateTable(
|
||
|
|
name: "DataSources",
|
||
|
|
columns: table => new
|
||
|
|
{
|
||
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
||
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||
|
|
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||
|
|
Description = table.Column<string>(type: "text", nullable: true),
|
||
|
|
ApiUrl = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true),
|
||
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||
|
|
},
|
||
|
|
constraints: table =>
|
||
|
|
{
|
||
|
|
table.PrimaryKey("PK_DataSources", x => x.Id);
|
||
|
|
});
|
||
|
|
|
||
|
|
migrationBuilder.CreateTable(
|
||
|
|
name: "Products",
|
||
|
|
columns: table => new
|
||
|
|
{
|
||
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
||
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||
|
|
Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false),
|
||
|
|
Model = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||
|
|
Manufacturer = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||
|
|
ReleaseDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
ImageUrl = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true),
|
||
|
|
CategoryId = table.Column<int>(type: "int", nullable: false),
|
||
|
|
CurrentRank = table.Column<int>(type: "int", nullable: true),
|
||
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||
|
|
},
|
||
|
|
constraints: table =>
|
||
|
|
{
|
||
|
|
table.PrimaryKey("PK_Products", x => x.Id);
|
||
|
|
table.ForeignKey(
|
||
|
|
name: "FK_Products_Categories_CategoryId",
|
||
|
|
column: x => x.CategoryId,
|
||
|
|
principalTable: "Categories",
|
||
|
|
principalColumn: "Id",
|
||
|
|
onDelete: ReferentialAction.Cascade);
|
||
|
|
});
|
||
|
|
|
||
|
|
migrationBuilder.CreateTable(
|
||
|
|
name: "PerformanceScores",
|
||
|
|
columns: table => new
|
||
|
|
{
|
||
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
||
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||
|
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
||
|
|
BenchmarkType = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false),
|
||
|
|
Score = table.Column<decimal>(type: "decimal(10,2)", nullable: false),
|
||
|
|
TestDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
DataSourceId = table.Column<int>(type: "int", nullable: false),
|
||
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||
|
|
},
|
||
|
|
constraints: table =>
|
||
|
|
{
|
||
|
|
table.PrimaryKey("PK_PerformanceScores", x => x.Id);
|
||
|
|
table.ForeignKey(
|
||
|
|
name: "FK_PerformanceScores_DataSources_DataSourceId",
|
||
|
|
column: x => x.DataSourceId,
|
||
|
|
principalTable: "DataSources",
|
||
|
|
principalColumn: "Id",
|
||
|
|
onDelete: ReferentialAction.Cascade);
|
||
|
|
table.ForeignKey(
|
||
|
|
name: "FK_PerformanceScores_Products_ProductId",
|
||
|
|
column: x => x.ProductId,
|
||
|
|
principalTable: "Products",
|
||
|
|
principalColumn: "Id",
|
||
|
|
onDelete: ReferentialAction.Cascade);
|
||
|
|
});
|
||
|
|
|
||
|
|
migrationBuilder.CreateTable(
|
||
|
|
name: "RankingHistories",
|
||
|
|
columns: table => new
|
||
|
|
{
|
||
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
||
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||
|
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
||
|
|
Rank = table.Column<int>(type: "int", nullable: false),
|
||
|
|
CategoryId = table.Column<int>(type: "int", nullable: false),
|
||
|
|
RecordDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||
|
|
},
|
||
|
|
constraints: table =>
|
||
|
|
{
|
||
|
|
table.PrimaryKey("PK_RankingHistories", x => x.Id);
|
||
|
|
table.ForeignKey(
|
||
|
|
name: "FK_RankingHistories_Categories_CategoryId",
|
||
|
|
column: x => x.CategoryId,
|
||
|
|
principalTable: "Categories",
|
||
|
|
principalColumn: "Id",
|
||
|
|
onDelete: ReferentialAction.Cascade);
|
||
|
|
table.ForeignKey(
|
||
|
|
name: "FK_RankingHistories_Products_ProductId",
|
||
|
|
column: x => x.ProductId,
|
||
|
|
principalTable: "Products",
|
||
|
|
principalColumn: "Id",
|
||
|
|
onDelete: ReferentialAction.Cascade);
|
||
|
|
});
|
||
|
|
|
||
|
|
migrationBuilder.CreateTable(
|
||
|
|
name: "Specifications",
|
||
|
|
columns: table => new
|
||
|
|
{
|
||
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
||
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||
|
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
||
|
|
Key = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
|
||
|
|
Value = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: false),
|
||
|
|
Unit = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true),
|
||
|
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
||
|
|
},
|
||
|
|
constraints: table =>
|
||
|
|
{
|
||
|
|
table.PrimaryKey("PK_Specifications", x => x.Id);
|
||
|
|
table.ForeignKey(
|
||
|
|
name: "FK_Specifications_Products_ProductId",
|
||
|
|
column: x => x.ProductId,
|
||
|
|
principalTable: "Products",
|
||
|
|
principalColumn: "Id",
|
||
|
|
onDelete: ReferentialAction.Cascade);
|
||
|
|
});
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_PerformanceScores_BenchmarkType",
|
||
|
|
table: "PerformanceScores",
|
||
|
|
column: "BenchmarkType");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_PerformanceScores_ProductId",
|
||
|
|
table: "PerformanceScores",
|
||
|
|
column: "ProductId");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_Products_CategoryId",
|
||
|
|
table: "Products",
|
||
|
|
column: "CategoryId");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_Products_Manufacturer",
|
||
|
|
table: "Products",
|
||
|
|
column: "Manufacturer");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_Products_Model",
|
||
|
|
table: "Products",
|
||
|
|
column: "Model");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_Products_Name",
|
||
|
|
table: "Products",
|
||
|
|
column: "Name");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_RankingHistories_CategoryId",
|
||
|
|
table: "RankingHistories",
|
||
|
|
column: "CategoryId");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_RankingHistories_ProductId",
|
||
|
|
table: "RankingHistories",
|
||
|
|
column: "ProductId");
|
||
|
|
|
||
|
|
migrationBuilder.CreateIndex(
|
||
|
|
name: "IX_Specifications_ProductId",
|
||
|
|
table: "Specifications",
|
||
|
|
column: "ProductId");
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <inheritdoc />
|
||
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||
|
|
{
|
||
|
|
migrationBuilder.DropTable(
|
||
|
|
name: "PerformanceScores");
|
||
|
|
|
||
|
|
migrationBuilder.DropTable(
|
||
|
|
name: "RankingHistories");
|
||
|
|
|
||
|
|
migrationBuilder.DropTable(
|
||
|
|
name: "Specifications");
|
||
|
|
|
||
|
|
migrationBuilder.DropTable(
|
||
|
|
name: "DataSources");
|
||
|
|
|
||
|
|
migrationBuilder.DropTable(
|
||
|
|
name: "Products");
|
||
|
|
|
||
|
|
migrationBuilder.DropTable(
|
||
|
|
name: "Categories");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|