<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddLocationToUsers extends Migration
{
    public function up()
    {
        if (!$this->db->fieldExists('location', 'users')) {
            $this->forge->addColumn('users', [
                'location' => [
                    'type' => 'TEXT',
                    'null' => true,
                    'after' => 'address',
                ],
            ]);
        }
    }

    public function down()
    {
        if ($this->db->fieldExists('location', 'users')) {
            $this->forge->dropColumn('users', 'location');
        }
    }
}
