using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ColaFlow.Modules.Identity.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddPerformanceIndexes : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // Index for email lookups (case-insensitive for PostgreSQL)
            migrationBuilder.Sql(@"
                CREATE INDEX IF NOT EXISTS idx_users_email_lower
                ON identity.users(LOWER(email));
            ");

            // Only create indexes for tables that exist
            // Note: Some tables may not have been moved to identity schema yet
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql("DROP INDEX IF EXISTS identity.idx_users_email_lower;");
        }
    }
}
