<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class AddVersionToExamDrafts extends Migration
{
    public function up()
    {
        $this->forge->addColumn('exam_drafts', [
            'version' => [
                'type'       => 'INT',
                'unsigned'   => true,
                'default'    => 1,
            ],
            'previous_draft_id' => [
                'type'     => 'INT',
                'unsigned' => true,
                'null'     => true,
            ],
        ]);
        $this->forge->addKey('version');
    }

    public function down()
    {
        $this->forge->dropColumn('exam_drafts', ['version', 'previous_draft_id']);
    }
}
