AMS_Backend/app/Database/Migrations/2025-11-05-031045_CreateStaffDetails.php
2025-11-06 13:41:06 +08:00

39 lines
1.7 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateStaffDetails extends Migration
{
public function up()
{
$this->forge->addField([
'staff_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'employee_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'email' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'phone_no' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
'bank_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'bank_acc_no' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'resign_date' => ['type' => 'DATE', 'null' => true],
'position_id' => ['type' => 'INT', 'unsigned' => true],
'username' => ['type' => 'VARCHAR', 'constraint' => 100],
'password' => ['type' => 'VARCHAR', 'constraint' => 255],
'branch_id' => ['type' => 'INT', 'unsigned' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('staff_id', true);
$this->forge->addForeignKey('position_id', 'position', 'position_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('branch_id', 'branch_details', 'branch_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('staff_details');
}
public function down()
{
$this->forge->dropTable('staff_details');
}
}