Files
alrahma_sunday_school/app/Database/Migrations/2026-01-27-200000_AddVersionToExamDrafts.php
T
2026-08-15 15:07:16 -04:00

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']);
}
}