<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * Control DB. Adds billing-communication contact fields to `tenants` —
 * needed once the platform starts invoicing hotels for their own PMS
 * subscription (see CreateInvoicesTable) rather than just hosting them.
 * Subscription/plan assignment itself lives in `subscriptions`, not here —
 * this table stays "who is this hotel and how do we reach them," same as
 * it always has.
 */
class AlterTenantsTableAddBillingFields extends Migration
{
    public function up()
    {
        $this->forge->addColumn('tenants', [
            'contact_email' => [
                'type'       => 'VARCHAR',
                'constraint' => 150,
                'null'       => true,
                'after'      => 'hotel_name',
                'comment'    => 'Billing/ops contact for the hotel account — invoices and platform notices go here, distinct from any individual staff user email.',
            ],
            'contact_phone' => [
                'type'       => 'VARCHAR',
                'constraint' => 20,
                'null'       => true,
                'after'      => 'contact_email',
            ],
        ]);
    }

    public function down()
    {
        $this->forge->dropColumn('tenants', ['contact_email', 'contact_phone']);
    }
}
