using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Commerce.Domain.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:hstore", ",,"); migrationBuilder.CreateTable( name: "Categorys", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), Photos = table.Column(type: "text[]", nullable: false), ParentCategoryId = table.Column(type: "uuid", nullable: true), IsBundle = table.Column(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(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), Photos = table.Column(type: "text[]", nullable: false), TechnicalDetails = table.Column>(type: "hstore", nullable: false), Price = table.Column(type: "double precision", nullable: false), Discount = table.Column(type: "double precision", nullable: false), Created = table.Column(type: "timestamp with time zone", nullable: false), CodeName = table.Column(type: "text", nullable: false), IsBundle = table.Column(type: "boolean", nullable: false), CategoryName = table.Column(type: "text", nullable: true), CategoryId = table.Column(type: "uuid", nullable: false), ProductId = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Products"); migrationBuilder.DropTable( name: "Categorys"); } } }