Files
2026-08-05 21:15:15 +03:00

100 lines
4.2 KiB
C#

using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Commerce.Domain.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("Npgsql:PostgresExtension:hstore", ",,");
migrationBuilder.CreateTable(
name: "Categorys",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Photos = table.Column<string[]>(type: "text[]", nullable: false),
ParentCategoryId = table.Column<Guid>(type: "uuid", nullable: true),
IsBundle = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Categorys", x => x.Id);
table.ForeignKey(
name: "FK_Categorys_Categorys_ParentCategoryId",
column: x => x.ParentCategoryId,
principalTable: "Categorys",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Photos = table.Column<string[]>(type: "text[]", nullable: false),
TechnicalDetails = table.Column<Dictionary<string, string>>(type: "hstore", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false),
Discount = table.Column<double>(type: "double precision", nullable: false),
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
CodeName = table.Column<string>(type: "text", nullable: false),
IsBundle = table.Column<bool>(type: "boolean", nullable: false),
CategoryName = table.Column<string>(type: "text", nullable: true),
CategoryId = table.Column<Guid>(type: "uuid", nullable: false),
ProductId = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Products", x => x.Id);
table.ForeignKey(
name: "FK_Products_Categorys_CategoryId",
column: x => x.CategoryId,
principalTable: "Categorys",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Products_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Categorys_ParentCategoryId",
table: "Categorys",
column: "ParentCategoryId");
migrationBuilder.CreateIndex(
name: "IX_Products_CategoryId",
table: "Products",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_Products_ProductId",
table: "Products",
column: "ProductId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
name: "Categorys");
}
}
}