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.
111 lines
3.3 KiB
PHP
111 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateEmployee extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addField([
|
|
'employee_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
'auto_increment' => true,
|
|
],
|
|
'company_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
'dept_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
'job_title_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
'emp_status_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true,
|
|
],
|
|
|
|
'company_issued_id' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 25,
|
|
],
|
|
'last_name' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
],
|
|
'first_name' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
'null' => true,
|
|
],
|
|
'middle_name' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
'null' => true,
|
|
],
|
|
'suffix' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 10,
|
|
'null' => true,
|
|
],
|
|
'email_address' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 255,
|
|
'null' => true,
|
|
],
|
|
'contact_number' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 20,
|
|
'null' => true,
|
|
],
|
|
|
|
// Common fields
|
|
'created_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
'created_by' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => '20',
|
|
'null' => true
|
|
],
|
|
'updated_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
'updated_by' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => '20',
|
|
'null' => true
|
|
],
|
|
'deleted_at' => [
|
|
'type' => 'DATETIME',
|
|
'null' => true,
|
|
],
|
|
]);
|
|
$this->forge->addKey('employee_id', true);
|
|
$this->forge->addForeignKey('company_id', 'company_info', 'company_id', 'CASCADE', 'RESTRICT');
|
|
$this->forge->addForeignKey('branch_code', 'company_branch', 'branch_code', 'CASCADE', 'RESTRICT');
|
|
$this->forge->addForeignKey('dept_id', 'company_dept', 'dept_id', 'CASCADE', 'RESTRICT');
|
|
$this->forge->addForeignKey('job_title_id', 'job_title', 'job_title_id', 'CASCADE', 'RESTRICT');
|
|
$this->forge->addForeignKey('emp_status_id', 'emp_status', 'emp_status_id', 'CASCADE', 'RESTRICT');
|
|
$this->forge->createTable('employee');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('employee');
|
|
}
|
|
}
|