39 lines
910 B
PHP
39 lines
910 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class AddVersionToExamDrafts extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$fields = [];
|
|
|
|
if (! $this->db->fieldExists('version', 'exam_drafts')) {
|
|
$fields['version'] = [
|
|
'type' => 'INT',
|
|
'unsigned' => true,
|
|
'default' => 1,
|
|
];
|
|
}
|
|
|
|
if (! $this->db->fieldExists('previous_draft_id', 'exam_drafts')) {
|
|
$fields['previous_draft_id'] = [
|
|
'type' => 'INT',
|
|
'unsigned' => true,
|
|
'null' => true,
|
|
];
|
|
}
|
|
|
|
if ($fields !== []) {
|
|
$this->forge->addColumn('exam_drafts', $fields);
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropColumn('exam_drafts', ['version', 'previous_draft_id']);
|
|
}
|
|
}
|