<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * Kept deliberately separate from the existing staff-entered preference
 * columns (bed_type, dietary_restrictions, ...) — this one is never
 * staff-typed, only ever written by `php spark ai:infer-guest-preferences`
 * (see App\Commands\InferGuestPreferences), from that guest's own real
 * folio/POS order history and notes. Staff-facing only: never shown to
 * the guest, never referenced anywhere pricing is decided. `ai_inferred_at`
 * lets staff see how stale the summary is (a guest's habits from a stay
 * 8 months ago may no longer hold).
 */
class AddAiInferredSummaryToGuestPreferences extends Migration
{
    public function up()
    {
        $this->forge->addColumn('guest_preferences', [
            'ai_inferred_summary' => [
                'type' => 'TEXT',
                'null' => true,
                'after' => 'other_notes',
            ],
            'ai_inferred_at' => [
                'type' => 'DATETIME',
                'null' => true,
                'after' => 'ai_inferred_summary',
            ],
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('guest_preferences', ['ai_inferred_summary', 'ai_inferred_at']);
    }
}
