using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AfRApay.Web.Backend.Database.Migrations
{
    /// <inheritdoc />
    public partial class _65F053DBD1B94D26B49463452C498D74 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "CardType",
                table: "Cards",
                type: "INTEGER",
                nullable: false,
                defaultValue: 0);
                
            // Detect AfRA door tokens
            migrationBuilder.Sql("UPDATE Cards SET CardType = 10 WHERE LENGTH(CardId) = 10 AND CardId GLOB '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'");
        }

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