clqms-be/app/Database/Migrations/2025-10-12-100001_RefRange.php
2025-12-11 16:43:19 +07:00

87 lines
3.9 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateRefRangesTable extends Migration {
public function up() {
$this->forge->addField([
'RefNumID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'TestSiteID' => ['type' => 'INT', 'null' => false],
'SpcType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => false],
'Sex' => ['type' => 'INT', 'null' => true],
'Criteria' => ['type' => 'varchar', 'constraint'=>100, 'null' => true],
'AgeStart' => ['type' => 'INT', 'null' => true],
'AgeEnd' => ['type' => 'int', 'null' => true],
'CriticalLow' => ['type' => 'int', 'null' => true],
'Low' => ['type' => 'int', 'null' => true],
'High' => ['type' => 'int', 'null' => true],
'CriticalHigh' => ['type' => 'int', 'null' => true],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'Datetime', 'null' => true],
]);
$this->forge->addKey('RefNumID', true);
$this->forge->createTable('refnum');
$this->forge->addField([
'RefTHoldID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'TestSiteID' => ['type' => 'INT', 'null' => false],
'SpcType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => false],
'Sex' => ['type' => 'INT', 'null' => true],
'AgeStart' => ['type' => 'INT', 'null' => true],
'AgeEnd' => ['type' => 'int', 'null' => true],
'TholdSign' => ['type' => 'int', 'null' => true],
'TholdValue' => ['type' => 'int', 'null' => true],
'BelowTxt' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
'AboveTxt' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
'GrayZoneLow' => ['type' => 'int', 'null' => true],
'GrayZoneHigh' => ['type' => 'int', 'null' => true],
'GrayZoneTxt' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'Datetime', 'null' => true],
]);
$this->forge->addKey('RefTHoldID', true);
$this->forge->createTable('refthold');
$this->forge->addField([
'RefVSetID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'TestSiteID' => ['type' => 'INT', 'null' => false],
'SpcType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => false],
'Sex' => ['type' => 'INT', 'null' => true],
'AgeStart' => ['type' => 'INT', 'null' => true],
'AgeEnd' => ['type' => 'int', 'null' => true],
'RefTxt' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'Datetime', 'null' => true],
]);
$this->forge->addKey('RefVSetID', true);
$this->forge->createTable('refvset');
$this->forge->addField([
'RefTxtID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'TestSiteID' => ['type' => 'INT', 'null' => false],
'SpcType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => false],
'Sex' => ['type' => 'INT', 'null' => true],
'AgeStart' => ['type' => 'INT', 'null' => true],
'AgeEnd' => ['type' => 'int', 'null' => true],
'RefTxt' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'Datetime', 'null' => true],
]);
$this->forge->addKey('RefTxtID', true);
$this->forge->createTable('reftxt');
}
public function down() {
$this->forge->dropTable('refnum');
$this->forge->dropTable('refthold');
$this->forge->dropTable('refvset');
$this->forge->dropTable('reftxt');
}
}