using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
    /// <inheritdoc />
    public partial class AddTeachingVenueNatures : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "TeachingVenueNature",
                table: "Classrooms",
                type: "int",
                nullable: false,
                defaultValue: 1);

            migrationBuilder.Sql("""
                UPDATE `Classrooms`
                SET `TeachingVenueNature` = CASE
                    WHEN `RoomType` LIKE '%机房%' THEN 10
                    WHEN `RoomType` LIKE '%语音%' THEN 18
                    WHEN `RoomType` LIKE '%实训%' THEN 4
                    WHEN `RoomType` LIKE '%实验%' THEN 2
                    WHEN `RoomType` LIKE '%体育%' THEN 32
                    WHEN `RoomType` LIKE '%艺术%' THEN 64
                    ELSE 1
                END;
                """);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "TeachingVenueNature",
                table: "Classrooms");
        }
    }
}
