<?php

namespace Tenant\Database\Migrations;

use CodeIgniter\Database\Migration;

class CreateRoomTypesTable extends Migration
{
    public function up()
    {
        $this->forge->addField([
            'id' => [
                'type'           => 'INT',
                'constraint'     => 11,
                'unsigned'       => true,
                'auto_increment' => true,
            ],
            'name' => [
                'type'       => 'VARCHAR',
                'constraint' => 150,
            ],
            'description' => [
                'type' => 'TEXT',
                'null' => true,
            ],
            'base_rate' => [
                'type'       => 'DECIMAL',
                'constraint' => '10,2',
                'comment'    => 'GHS. Never float — see app/Helpers/money_helper.php',
            ],
            'capacity' => [
                'type'       => 'INT',
                'constraint' => 5,
                'unsigned'   => true,
                'default'    => 2,
            ],
            'amenities' => [
                'type'    => 'TEXT',
                'null'    => true,
                'comment' => 'JSON-encoded list of amenity strings',
            ],
            'photo_path' => [
                'type'       => 'VARCHAR',
                'constraint' => 255,
                'null'       => true,
            ],
            'created_at' => ['type' => 'DATETIME', 'null' => true],
            'updated_at' => ['type' => 'DATETIME', 'null' => true],
        ]);

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

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