42 lines
930 B
PHP
42 lines
930 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class AddStudentActiveFlag extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$db = \Config\Database::connect();
|
|
|
|
if (!$db->tableExists('students')) {
|
|
return;
|
|
}
|
|
|
|
if (!$db->fieldExists('is_active', 'students')) {
|
|
$this->forge->addColumn('students', [
|
|
'is_active' => [
|
|
'type' => 'TINYINT',
|
|
'constraint' => 1,
|
|
'default' => 1,
|
|
'null' => false,
|
|
],
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$db = \Config\Database::connect();
|
|
|
|
if (!$db->tableExists('students')) {
|
|
return;
|
|
}
|
|
|
|
if ($db->fieldExists('is_active', 'students')) {
|
|
$this->forge->dropColumn('students', 'is_active');
|
|
}
|
|
}
|
|
}
|