using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Zentral.Infrastructure.Migrations { /// public partial class AddWarehouseProductGroups : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "ProductGroupId", table: "WarehouseArticles", type: "INTEGER", nullable: true); migrationBuilder.CreateTable( name: "WarehouseProductGroups", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Code = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: false), Description = table.Column(type: "TEXT", nullable: true), IsActive = table.Column(type: "INTEGER", nullable: false), Notes = table.Column(type: "TEXT", nullable: true), CreatedAt = table.Column(type: "TEXT", nullable: true), CreatedBy = table.Column(type: "TEXT", nullable: true), UpdatedAt = table.Column(type: "TEXT", nullable: true), UpdatedBy = table.Column(type: "TEXT", nullable: true), CustomFieldsJson = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_WarehouseProductGroups", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_WarehouseArticles_ProductGroupId", table: "WarehouseArticles", column: "ProductGroupId"); migrationBuilder.CreateIndex( name: "IX_WarehouseProductGroups_Code", table: "WarehouseProductGroups", column: "Code", unique: true); migrationBuilder.CreateIndex( name: "IX_WarehouseProductGroups_IsActive", table: "WarehouseProductGroups", column: "IsActive"); migrationBuilder.AddForeignKey( name: "FK_WarehouseArticles_WarehouseProductGroups_ProductGroupId", table: "WarehouseArticles", column: "ProductGroupId", principalTable: "WarehouseProductGroups", principalColumn: "Id", onDelete: ReferentialAction.SetNull); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_WarehouseArticles_WarehouseProductGroups_ProductGroupId", table: "WarehouseArticles"); migrationBuilder.DropTable( name: "WarehouseProductGroups"); migrationBuilder.DropIndex( name: "IX_WarehouseArticles_ProductGroupId", table: "WarehouseArticles"); migrationBuilder.DropColumn( name: "ProductGroupId", table: "WarehouseArticles"); } } }