You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kwpayroll/app/Database/Migrations/2024-09-05-220011_AddBranch...

33 lines
836 B
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class AddBranchOnEmployee extends Migration
{
public function up()
{
$fields = [
'branch_code' => [
'type' => 'VARCHAR',
'constraint' => 25,
'null' => false,
'after' => 'company_id',
],
];
$this->forge->addColumn('employee', $fields);
$this->forge->addForeignKey('branch_code', 'company_branch', 'branch_code', 'CASCADE', 'RESTRICT');
$this->forge->processIndexes('employee');
}
public function down()
{
$this->forge->dropForeignKey('employee', 'employee_branch_code_foreign');
$this->forge->processIndexes('employee');
$this->forge->dropColumn('employee', 'branch_code');
}
}