using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ERPCore.Migrations
{
    /// <inheritdoc />
    public partial class AddBundleSaleToDayEnd : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "BundleCount",
                table: "sales_day_ends",
                type: "integer",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<int>(
                name: "DayEndId",
                table: "bundle_sales",
                type: "integer",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_bundle_sales_DayEndId",
                table: "bundle_sales",
                column: "DayEndId");

            migrationBuilder.AddForeignKey(
                name: "FK_bundle_sales_sales_day_ends_DayEndId",
                table: "bundle_sales",
                column: "DayEndId",
                principalTable: "sales_day_ends",
                principalColumn: "SalesDayEndId",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_bundle_sales_sales_day_ends_DayEndId",
                table: "bundle_sales");

            migrationBuilder.DropIndex(
                name: "IX_bundle_sales_DayEndId",
                table: "bundle_sales");

            migrationBuilder.DropColumn(
                name: "BundleCount",
                table: "sales_day_ends");

            migrationBuilder.DropColumn(
                name: "DayEndId",
                table: "bundle_sales");
        }
    }
}
