<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddPhotoToUsers extends Migration
{
    public function up()
    {
        if (!$this->db->fieldExists('photo', 'users')) {
            $this->forge->addColumn('users', [
                'photo' => [
                    'type' => 'VARCHAR',
                    'constraint' => 255,
                    'null' => true,
                    'after' => 'email',
                ],
            ]);
        }
    }

    public function down()
    {
        $this->forge->dropColumn('users', 'photo');
    }
}
