using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Distribution.Migrations { /// public partial class AddDirectGoodsReceipt : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterColumn( name: "FK_PurchaseOrderId", table: "GoodsReceipts", type: "char(36)", nullable: true, collation: "ascii_general_ci", oldClrType: typeof(Guid), oldType: "char(36)") .OldAnnotation("Relational:Collation", "ascii_general_ci"); migrationBuilder.AddColumn( name: "FK_SupplierId", table: "GoodsReceipts", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AlterColumn( name: "FK_PurchaseOrderItemId", table: "GoodsReceiptItems", type: "char(36)", nullable: true, collation: "ascii_general_ci", oldClrType: typeof(Guid), oldType: "char(36)") .OldAnnotation("Relational:Collation", "ascii_general_ci"); migrationBuilder.AddColumn( name: "FK_ItemId", table: "GoodsReceiptItems", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.UpdateData( table: "GoodsReceiptItems", keyColumn: "Id", keyValue: new Guid("44000000-0000-0000-0000-000000000001"), column: "FK_ItemId", value: null); migrationBuilder.UpdateData( table: "GoodsReceiptItems", keyColumn: "Id", keyValue: new Guid("44000000-0000-0000-0000-000000000002"), column: "FK_ItemId", value: null); migrationBuilder.UpdateData( table: "GoodsReceipts", keyColumn: "Id", keyValue: new Guid("43000000-0000-0000-0000-000000000001"), column: "FK_SupplierId", value: null); migrationBuilder.CreateIndex( name: "IX_GoodsReceipts_FK_SupplierId", table: "GoodsReceipts", column: "FK_SupplierId"); migrationBuilder.CreateIndex( name: "IX_GoodsReceiptItems_FK_ItemId", table: "GoodsReceiptItems", column: "FK_ItemId"); migrationBuilder.AddForeignKey( name: "FK_GoodsReceiptItems_Items_FK_ItemId", table: "GoodsReceiptItems", column: "FK_ItemId", principalTable: "Items", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_GoodsReceipts_Suppliers_FK_SupplierId", table: "GoodsReceipts", column: "FK_SupplierId", principalTable: "Suppliers", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_GoodsReceiptItems_Items_FK_ItemId", table: "GoodsReceiptItems"); migrationBuilder.DropForeignKey( name: "FK_GoodsReceipts_Suppliers_FK_SupplierId", table: "GoodsReceipts"); migrationBuilder.DropIndex( name: "IX_GoodsReceipts_FK_SupplierId", table: "GoodsReceipts"); migrationBuilder.DropIndex( name: "IX_GoodsReceiptItems_FK_ItemId", table: "GoodsReceiptItems"); migrationBuilder.DropColumn( name: "FK_SupplierId", table: "GoodsReceipts"); migrationBuilder.DropColumn( name: "FK_ItemId", table: "GoodsReceiptItems"); migrationBuilder.AlterColumn( name: "FK_PurchaseOrderId", table: "GoodsReceipts", type: "char(36)", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), collation: "ascii_general_ci", oldClrType: typeof(Guid), oldType: "char(36)", oldNullable: true) .OldAnnotation("Relational:Collation", "ascii_general_ci"); migrationBuilder.AlterColumn( name: "FK_PurchaseOrderItemId", table: "GoodsReceiptItems", type: "char(36)", nullable: false, defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), collation: "ascii_general_ci", oldClrType: typeof(Guid), oldType: "char(36)", oldNullable: true) .OldAnnotation("Relational:Collation", "ascii_general_ci"); } } }