49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class UseNumericStatusForDoctorSpecializations extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if (! $this->db->tableExists('doctor_specializations') || ! $this->db->fieldExists('status', 'doctor_specializations')) {
|
|
return;
|
|
}
|
|
|
|
$this->db->query("UPDATE `doctor_specializations` SET `status` = '1' WHERE `status` IS NULL OR `status` = '' OR LOWER(`status`) = 'active'");
|
|
$this->db->query("UPDATE `doctor_specializations` SET `status` = '0' WHERE LOWER(`status`) = 'inactive'");
|
|
|
|
$this->forge->modifyColumn('doctor_specializations', [
|
|
'status' => [
|
|
'name' => 'status',
|
|
'type' => 'TINYINT',
|
|
'constraint' => 1,
|
|
'null' => false,
|
|
'default' => 1,
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
if (! $this->db->tableExists('doctor_specializations') || ! $this->db->fieldExists('status', 'doctor_specializations')) {
|
|
return;
|
|
}
|
|
|
|
$this->db->query("UPDATE `doctor_specializations` SET `status` = 'active' WHERE `status` = 1");
|
|
$this->db->query("UPDATE `doctor_specializations` SET `status` = 'inactive' WHERE `status` = 0");
|
|
|
|
$this->forge->modifyColumn('doctor_specializations', [
|
|
'status' => [
|
|
'name' => 'status',
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 20,
|
|
'null' => false,
|
|
'default' => 'active',
|
|
],
|
|
]);
|
|
}
|
|
}
|