42 lines
977 B
PHP
42 lines
977 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class AddNoSchoolToCalendarEvents extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$db = \Config\Database::connect();
|
|
$cols = [];
|
|
try {
|
|
$cols = $db->getFieldNames('calendar_events');
|
|
} catch (\Throwable $e) {
|
|
$cols = [];
|
|
}
|
|
|
|
if (!in_array('no_school', $cols, true)) {
|
|
$this->forge->addColumn('calendar_events', [
|
|
'no_school' => [
|
|
'type' => 'TINYINT',
|
|
'constraint' => 1,
|
|
'null' => false,
|
|
'default' => 0,
|
|
'after' => 'notify_teacher',
|
|
],
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
try {
|
|
$this->forge->dropColumn('calendar_events', 'no_school');
|
|
} catch (\Throwable $e) {
|
|
// ignore
|
|
}
|
|
}
|
|
}
|
|
|