Files
alrahma_sunday_school/app/Database/Migrations/2025-10-17-121500_AddNoSchoolToCalendarEvents.php
root 716cc8b8d3
Tests / PHPUnit (push) Failing after 1m20s
fix school year for all tables
2026-07-18 14:45:38 -04:00

49 lines
1.1 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddNoSchoolToCalendarEvents extends Migration
{
public function up()
{
$db = \Config\Database::connect();
if (! $db->tableExists('calendar_events')) {
return;
}
$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()
{
if (! $this->db->tableExists('calendar_events')) {
return;
}
try {
$this->forge->dropColumn('calendar_events', 'no_school');
} catch (\Throwable $e) {
// ignore
}
}
}