Files
alrahma_sunday_school/app/Database/Migrations/2025-10-17-121500_AddNoSchoolToCalendarEvents.php
T
2026-02-10 22:11:06 -05:00

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
}
}
}