db->tableExists('doctor_specializations')) { return; } $fields = []; if (! $this->db->fieldExists('status', 'doctor_specializations')) { $fields['status'] = [ 'type' => 'TINYINT', 'constraint' => 1, 'default' => 1, 'after' => 'specialization_id', ]; } if (! $this->db->fieldExists('created_at', 'doctor_specializations')) { $fields['created_at'] = [ 'type' => 'DATETIME', 'null' => true, 'after' => 'status', ]; } if (! $this->db->fieldExists('updated_at', 'doctor_specializations')) { $fields['updated_at'] = [ 'type' => 'DATETIME', 'null' => true, 'after' => 'created_at', ]; } if (! $this->db->fieldExists('created_by', 'doctor_specializations')) { $fields['created_by'] = [ 'type' => 'INT', 'unsigned' => true, 'null' => true, 'after' => 'updated_at', ]; } if (! $this->db->fieldExists('updated_by', 'doctor_specializations')) { $fields['updated_by'] = [ 'type' => 'INT', 'unsigned' => true, 'null' => true, 'after' => 'created_by', ]; } if ($fields !== []) { $this->forge->addColumn('doctor_specializations', $fields); } $now = date('Y-m-d H:i:s'); $this->db->table('doctor_specializations')->set([ 'status' => 1, 'created_at' => $now, 'updated_at' => $now, ])->update(); } public function down(): void { if (! $this->db->tableExists('doctor_specializations')) { return; } foreach (['updated_by', 'created_by', 'updated_at', 'created_at', 'status'] as $field) { if ($this->db->fieldExists($field, 'doctor_specializations')) { $this->forge->dropColumn('doctor_specializations', $field); } } } }