using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Baya.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class RefinementPhase3TierC : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<DateTimeOffset>(
                name: "LastReadAt",
                schema: "messaging",
                table: "TicketParticipants",
                type: "datetimeoffset",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "ClientMessageId",
                schema: "messaging",
                table: "TicketMessages",
                type: "nvarchar(100)",
                maxLength: 100,
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "UX_TicketMessages_Ticket_ClientMessageId",
                schema: "messaging",
                table: "TicketMessages",
                columns: new[] { "TicketId", "ClientMessageId" },
                unique: true,
                filter: "[ClientMessageId] IS NOT NULL AND [DeletedAt] IS NULL");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "UX_TicketMessages_Ticket_ClientMessageId",
                schema: "messaging",
                table: "TicketMessages");

            migrationBuilder.DropColumn(
                name: "LastReadAt",
                schema: "messaging",
                table: "TicketParticipants");

            migrationBuilder.DropColumn(
                name: "ClientMessageId",
                schema: "messaging",
                table: "TicketMessages");
        }
    }
}
