using Jiaowu.Api.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql;

[DbContext(typeof(AppDbContext))]
[Migration("20260726022634_AttendanceCheckIn")]
public partial class AttendanceCheckIn : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.AddColumn<int>(
            name: "CheckInMethod",
            table: "AttendanceSheets",
            type: "int",
            nullable: false,
            defaultValue: 1);

        migrationBuilder.AddColumn<string>(
            name: "CheckInToken",
            table: "AttendanceSheets",
            type: "varchar(64)",
            maxLength: 64,
            nullable: true)
            .Annotation("MySql:CharSet", "utf8mb4");

        migrationBuilder.AddColumn<DateTime>(
            name: "CheckInStartsAt",
            table: "AttendanceSheets",
            type: "datetime(6)",
            nullable: true);

        migrationBuilder.AddColumn<DateTime>(
            name: "CheckInEndsAt",
            table: "AttendanceSheets",
            type: "datetime(6)",
            nullable: true);

        migrationBuilder.AddColumn<decimal>(
            name: "TargetLatitude",
            table: "AttendanceSheets",
            type: "decimal(10,7)",
            precision: 10,
            scale: 7,
            nullable: true);

        migrationBuilder.AddColumn<decimal>(
            name: "TargetLongitude",
            table: "AttendanceSheets",
            type: "decimal(10,7)",
            precision: 10,
            scale: 7,
            nullable: true);

        migrationBuilder.AddColumn<int>(
            name: "LocationRadiusMeters",
            table: "AttendanceSheets",
            type: "int",
            nullable: true);

        migrationBuilder.AddColumn<DateTime>(
            name: "CheckInAt",
            table: "AttendanceRecords",
            type: "datetime(6)",
            nullable: true);

        migrationBuilder.AddColumn<int>(
            name: "CheckedInMethod",
            table: "AttendanceRecords",
            type: "int",
            nullable: true);

        migrationBuilder.AddColumn<decimal>(
            name: "CheckInLatitude",
            table: "AttendanceRecords",
            type: "decimal(10,7)",
            precision: 10,
            scale: 7,
            nullable: true);

        migrationBuilder.AddColumn<decimal>(
            name: "CheckInLongitude",
            table: "AttendanceRecords",
            type: "decimal(10,7)",
            precision: 10,
            scale: 7,
            nullable: true);

        migrationBuilder.AddColumn<double>(
            name: "CheckInAccuracyMeters",
            table: "AttendanceRecords",
            type: "double",
            nullable: true);

        migrationBuilder.AddColumn<double>(
            name: "CheckInDistanceMeters",
            table: "AttendanceRecords",
            type: "double",
            nullable: true);

        migrationBuilder.CreateIndex(
            name: "IX_AttendanceSheets_CheckInToken",
            table: "AttendanceSheets",
            column: "CheckInToken",
            unique: true);
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropIndex(
            name: "IX_AttendanceSheets_CheckInToken",
            table: "AttendanceSheets");

        migrationBuilder.DropColumn(name: "CheckInMethod", table: "AttendanceSheets");
        migrationBuilder.DropColumn(name: "CheckInToken", table: "AttendanceSheets");
        migrationBuilder.DropColumn(name: "CheckInStartsAt", table: "AttendanceSheets");
        migrationBuilder.DropColumn(name: "CheckInEndsAt", table: "AttendanceSheets");
        migrationBuilder.DropColumn(name: "TargetLatitude", table: "AttendanceSheets");
        migrationBuilder.DropColumn(name: "TargetLongitude", table: "AttendanceSheets");
        migrationBuilder.DropColumn(name: "LocationRadiusMeters", table: "AttendanceSheets");
        migrationBuilder.DropColumn(name: "CheckInAt", table: "AttendanceRecords");
        migrationBuilder.DropColumn(name: "CheckedInMethod", table: "AttendanceRecords");
        migrationBuilder.DropColumn(name: "CheckInLatitude", table: "AttendanceRecords");
        migrationBuilder.DropColumn(name: "CheckInLongitude", table: "AttendanceRecords");
        migrationBuilder.DropColumn(name: "CheckInAccuracyMeters", table: "AttendanceRecords");
        migrationBuilder.DropColumn(name: "CheckInDistanceMeters", table: "AttendanceRecords");
    }
}
