<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

/**
 * Lightweight record for company/corporate event clients who aren't in the
 * guest table — Phase 3 adds a proper `corporate_account` table; this is
 * deliberately minimal (not linked to it yet) rather than half-building
 * that structure early. `catering_preferences` lives here for company
 * clients; for a guest-linked event, Phase 1's guests.notes serves the
 * same purpose, so it isn't duplicated onto guests.
 */
class CreateEventClientsTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type'           => 'INT',
                'constraint'     => 11,
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'company_name' => [
                'type'       => 'VARCHAR',
                'constraint' => 150,
            ],
            'contact_name' => [
                'type'       => 'VARCHAR',
                'constraint' => 150,
                'null'       => true,
            ],
            'phone' => [
                'type'       => 'VARCHAR',
                'constraint' => 20,
                'null'       => true,
            ],
            'email' => [
                'type'       => 'VARCHAR',
                'constraint' => 150,
                'null'       => true,
            ],
            'catering_preferences' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'created_at' => ['type' => 'DATETIME', 'null' => true],
            'updated_at' => ['type' => 'DATETIME', 'null' => true],
        ]);

        $this->forge->addKey('id', true);
        $this->forge->createTable('event_clients');
    }

    public function down()
    {
        $this->forge->dropTable('event_clients', true);
    }
}
