<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

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

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