<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddJpPerWeekToLearningDevices extends Migration
{
    public function up()
    {
        if (!$this->db->fieldExists('jp_per_week', 'learning_devices')) {
            $this->forge->addColumn('learning_devices', [
                'jp_per_week' => [
                    'type'       => 'INT',
                    'constraint' => 11,
                    'default'    => 4,
                    'null'       => true,
                    'after'      => 'chapter_kbc'
                ]
            ]);
        }
    }

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