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

48 lines
1.5 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddTimezoneToPreferencesAndSettings extends Migration
{
public function up()
{
// user_preferences.timezone
if ($this->db->tableExists('user_preferences') && ! $this->db->fieldExists('timezone', 'user_preferences')) {
$this->forge->addColumn('user_preferences', [
'timezone' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
'after' => 'language',
],
]);
}
// settings.timezone (only if table exists)
if ($this->db->tableExists('settings') && ! $this->db->fieldExists('timezone', 'settings')) {
$this->forge->addColumn('settings', [
'timezone' => [
'type' => 'VARCHAR',
'constraint' => 64,
'null' => true,
'after' => 'name',
],
]);
}
}
public function down()
{
if ($this->db->tableExists('user_preferences') && $this->db->fieldExists('timezone', 'user_preferences')) {
$this->forge->dropColumn('user_preferences', 'timezone');
}
if ($this->db->tableExists('settings') && $this->db->fieldExists('timezone', 'settings')) {
$this->forge->dropColumn('settings', 'timezone');
}
}
}