67 lines
2.4 KiB
PHP
67 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class RenameApprovedByToProcessedBy extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
if ($this->db->fieldExists('approved_by', 'employees') && ! $this->db->fieldExists('processed_by', 'employees')) {
|
|
$this->forge->modifyColumn('employees', [
|
|
'approved_by' => [
|
|
'name' => 'processed_by',
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 50,
|
|
'null' => true,
|
|
'default' => null,
|
|
'comment' => 'Processor role: HR / ACM (approve or reject)',
|
|
],
|
|
]);
|
|
}
|
|
|
|
if ($this->db->fieldExists('approved_by', 'employee_polices') && ! $this->db->fieldExists('processed_by', 'employee_polices')) {
|
|
$this->forge->modifyColumn('employee_polices', [
|
|
'approved_by' => [
|
|
'name' => 'processed_by',
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 50,
|
|
'null' => true,
|
|
'default' => null,
|
|
'comment' => 'Processor role: HR / ACM (approve or reject)',
|
|
],
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
if ($this->db->fieldExists('processed_by', 'employees') && ! $this->db->fieldExists('approved_by', 'employees')) {
|
|
$this->forge->modifyColumn('employees', [
|
|
'processed_by' => [
|
|
'name' => 'approved_by',
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 50,
|
|
'null' => true,
|
|
'default' => null,
|
|
'comment' => 'Approver role: HR / ACM',
|
|
],
|
|
]);
|
|
}
|
|
|
|
if ($this->db->fieldExists('processed_by', 'employee_polices') && ! $this->db->fieldExists('approved_by', 'employee_polices')) {
|
|
$this->forge->modifyColumn('employee_polices', [
|
|
'processed_by' => [
|
|
'name' => 'approved_by',
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 50,
|
|
'null' => true,
|
|
'default' => null,
|
|
'comment' => 'Approver role: HR / ACM',
|
|
],
|
|
]);
|
|
}
|
|
}
|
|
}
|