using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql
{
    /// <inheritdoc />
    public partial class AppUpdateReleases : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AppUpdateReleases",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false),
                    Platform = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false),
                    Channel = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false),
                    Version = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false),
                    NativeVersion = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false),
                    Status = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false),
                    ReleaseNotes = table.Column<string>(type: "varchar(1000)", maxLength: 1000, nullable: true),
                    FileName = table.Column<string>(type: "varchar(180)", maxLength: 180, nullable: false),
                    FileSize = table.Column<long>(type: "bigint", nullable: false),
                    Sha256 = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false),
                    BundleContent = table.Column<byte[]>(type: "longblob", nullable: false),
                    CreatedByUserName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false),
                    PublishedByUserName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true),
                    PublishedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppUpdateReleases", x => x.Id);
                })
                .Annotation("MySQL:Charset", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_AppUpdateReleases_CreatedAt",
                table: "AppUpdateReleases",
                column: "CreatedAt");

            migrationBuilder.CreateIndex(
                name: "IX_AppUpdateReleases_Platform_Channel_NativeVersion_Status",
                table: "AppUpdateReleases",
                columns: new[] { "Platform", "Channel", "NativeVersion", "Status" });

            migrationBuilder.CreateIndex(
                name: "IX_AppUpdateReleases_Platform_Channel_NativeVersion_Version",
                table: "AppUpdateReleases",
                columns: new[] { "Platform", "Channel", "NativeVersion", "Version" },
                unique: true);
        }

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