<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * Two small additive fields for the Guest CRM redesign (a user-supplied
 * mockup showed VIP/Repeat/Blacklist tabs and a "Segment" column, neither
 * of which existed on guests before). Deliberately NOT adding the
 * mockup's guest "Preferences" (room type/bed/pillow/smoking/language) —
 * that's a materially bigger feature (a whole preferences UX) that wasn't
 * asked for; `notes` (already on this table since Phase 1) covers the
 * same "anything special about this guest" need without inventing five
 * new columns nobody's populated yet.
 */
class AddSegmentAndBlacklistToGuests extends Migration
{
    public function up()
    {
        $this->forge->addColumn('guests', [
            'segment' => [
                'type'       => 'VARCHAR',
                'constraint' => 20,
                'null'       => true,
                'after'      => 'nationality',
                'comment'    => 'vip|business|leisure — validated against Config\Lookups, plain string like every other open-ended field in this app. Null = untagged.',
            ],
            'is_blacklisted' => [
                'type'       => 'TINYINT',
                'constraint' => 1,
                'default'    => 0,
                'after'      => 'segment',
            ],
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('guests', ['segment', 'is_blacklisted']);
    }
}
