clqms-be/app/Database/Migrations/2025-10-23-110105_Organization.php
2025-10-24 11:19:58 +07:00

65 lines
2.8 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class Organization extends Migration {
public function up() {
$this->forge->addField([
'DisciplineID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
'DisciplineCode' => ['type' => 'varchar', 'constraint'=> 10, 'null'=> false],
'DisciplineName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
'EndDate' => ['type'=>'DATETIME', 'null' => true]
]);
$this->forge->addKey('DiciplineID', true);
$this->forge->createTable('discipline');
$this->forge->addField([
'DepartmentID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
'DisciplineID' => ['type' => 'int', 'null'=> false],
'SiteID' => ['type' => 'int', 'null'=> false],
'DepartmentCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
'DepartmentName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
'EndDate' => ['type'=>'DATETIME', 'null' => true]
]);
$this->forge->addKey('DepartmentID', true);
$this->forge->createTable('department');
$this->forge->addField([
'WorkstationID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
'DepartmentID' => ['type' => 'int', 'null'=> false],
'WorkstationCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
'WorkstationName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
'Type' => ['type' => 'tinyint', 'null'=> true],
'LinkTo' => ['type' => 'int', 'null'=> true],
'Enable' => ['type' => 'bit', 'null'=> true],
'EquipmentID' => ['type' => 'varchar', 'constraint'=>'10', 'null'=> true],
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
'EndDate' => ['type'=>'DATETIME', 'null' => true]
]);
$this->forge->addKey('WorkstationID', true);
$this->forge->createTable('workstation');
$this->forge->addField([
'WorkbenchID' => ['type' => 'int', 'unsigned' => true, 'auto_increment'=> true],
'DepartmentID' => ['type' => 'int', 'null'=> false],
'WorkbenchCode' => ['type' => 'varchar', 'constraint'=>10, 'null'=> false],
'WorkbenchName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
'EndDate' => ['type'=>'DATETIME', 'null' => true]
]);
$this->forge->addKey('WorkbenchID', true);
$this->forge->createTable('workbench');
}
public function down() {
$this->forge->dropTable('discipline', true);
$this->forge->dropTable('department', true);
$this->forge->dropTable('workstation', true);
$this->forge->dropTable('workbench', true);
}
}