using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SteUp.Data.Migrations
{
    /// <inheritdoc />
    public partial class AddListArticoli : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SchedaArticoli",
                columns: table => new
                {
                    Id = table.Column<int>(type: "INTEGER", nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    SchedaId = table.Column<int>(type: "INTEGER", nullable: false),
                    Barcode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
                    Descrizione = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SchedaArticoli", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SchedaArticoli_Schede_SchedaId",
                        column: x => x.SchedaId,
                        principalTable: "Schede",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_SchedaArticoli_SchedaId_Barcode",
                table: "SchedaArticoli",
                columns: new[] { "SchedaId", "Barcode" },
                unique: true);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SchedaArticoli");
        }
    }
}
