<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * Lets message_log also hold manually-logged calls/notes (channel
 * 'call'/'note', message_type 'manual_log') — the missing "every call...
 * in one guest timeline" piece, since this app has no telephony
 * integration to auto-capture a call. `to_phone` becomes nullable (a
 * note isn't "to" any number); `provider_response` — originally meant
 * for a gateway's raw API reply — doubles as the free-text note body for
 * these manual entries (documented on GuestController::logCommunication()
 * rather than adding a parallel `body` column for one entry type).
 * `status` gains a third real value, 'logged', alongside the existing
 * sent/failed, meaning "recorded, not sent via any provider."
 */
class AllowManualMessageLogEntries extends Migration
{
    public function up()
    {
        $this->forge->modifyColumn('message_log', [
            'to_phone' => [
                'type'       => 'VARCHAR',
                'constraint' => 20,
                'null'       => true,
            ],
        ]);
    }

    public function down()
    {
        $this->forge->modifyColumn('message_log', [
            'to_phone' => [
                'type'       => 'VARCHAR',
                'constraint' => 20,
                'null'       => false,
            ],
        ]);
    }
}
