Files
alrahma_sunday_school/app/Database/Migrations/2026-02-10-000100_AddStyleToPreferences.php
T
2026-02-10 22:11:06 -05:00

86 lines
3.3 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddStyleToPreferences extends Migration
{
public function up()
{
if ($this->db->tableExists('user_preferences')) {
if (! $this->db->fieldExists('style_color', 'user_preferences')) {
$this->forge->addColumn('user_preferences', [
'style_color' => [
'type' => 'VARCHAR',
'constraint' => 32,
'null' => true,
'after' => 'timezone',
],
]);
}
if (! $this->db->fieldExists('menu_color', 'user_preferences')) {
$this->forge->addColumn('user_preferences', [
'menu_color' => [
'type' => 'VARCHAR',
'constraint' => 32,
'null' => true,
'after' => 'style_color',
],
]);
}
if (! $this->db->fieldExists('menu_custom_bg', 'user_preferences')) {
$this->forge->addColumn('user_preferences', [
'menu_custom_bg' => [
'type' => 'VARCHAR',
'constraint' => 16,
'null' => true,
'after' => 'menu_color',
],
]);
}
if (! $this->db->fieldExists('menu_custom_text', 'user_preferences')) {
$this->forge->addColumn('user_preferences', [
'menu_custom_text' => [
'type' => 'VARCHAR',
'constraint' => 16,
'null' => true,
'after' => 'menu_custom_bg',
],
]);
}
if (! $this->db->fieldExists('menu_custom_mode', 'user_preferences')) {
$this->forge->addColumn('user_preferences', [
'menu_custom_mode' => [
'type' => 'VARCHAR',
'constraint' => 8,
'null' => true,
'after' => 'menu_custom_text',
],
]);
}
}
}
public function down()
{
if ($this->db->tableExists('user_preferences')) {
if ($this->db->fieldExists('menu_custom_mode', 'user_preferences')) {
$this->forge->dropColumn('user_preferences', 'menu_custom_mode');
}
if ($this->db->fieldExists('menu_custom_text', 'user_preferences')) {
$this->forge->dropColumn('user_preferences', 'menu_custom_text');
}
if ($this->db->fieldExists('menu_custom_bg', 'user_preferences')) {
$this->forge->dropColumn('user_preferences', 'menu_custom_bg');
}
if ($this->db->fieldExists('menu_color', 'user_preferences')) {
$this->forge->dropColumn('user_preferences', 'menu_color');
}
if ($this->db->fieldExists('style_color', 'user_preferences')) {
$this->forge->dropColumn('user_preferences', 'style_color');
}
}
}
}