<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddReviewRevisionToExamDrafts extends Migration
{
    public function up()
    {
        if (! $this->db->fieldExists('review_revision', 'exam_drafts')) {
            $this->forge->addColumn('exam_drafts', [
                'review_revision' => [
                    'type' => 'INT',
                    'constraint' => 11,
                    'null' => false,
                    'default' => 0,
                    'after' => 'version',
                ],
            ]);
        }
    }

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