167 lines
9.2 KiB
PHP
167 lines
9.2 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateTestDefinitions extends Migration {
|
|
public function up() {
|
|
$this->forge->addField([
|
|
'TestSiteID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'SiteID' => ['type' => 'INT', 'null' => false],
|
|
'TestSiteCode' => ['type' => 'varchar', 'constraint'=> 6, 'null' => false],
|
|
'TestSiteName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => false],
|
|
'TestType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => false],
|
|
'Description' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
|
// Technical details merged from testdeftech
|
|
'DisciplineID' => ['type' => 'INT', 'null' => true],
|
|
'DepartmentID' => ['type' => 'INT', 'null' => true],
|
|
'ResultType' => ['type' => 'VARCHAR', 'constraint'=> 20, 'null' => true],
|
|
'RefType' => ['type' => 'VARCHAR', 'constraint'=> 10, 'null' => true],
|
|
'VSet' => ['type' => 'INT', 'null' => true],
|
|
'ReqQty' => ['type' => 'DECIMAL', 'constraint'=> '10,2', 'null' => true],
|
|
'ReqQtyUnit' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
|
'Unit1' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
|
'Factor' => ['type' => 'DECIMAL', 'constraint'=> '10,4', 'null' => true],
|
|
'Unit2' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
|
'Decimal' => ['type' => 'int', 'null' => true, 'default' => 2],
|
|
'CollReq' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
|
'Method' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
|
'ExpectedTAT' => ['type' => 'INT', 'null' => true],
|
|
'SeqScr' => ['type' => 'int', 'null' => true],
|
|
'SeqRpt' => ['type' => 'int', 'null' => true],
|
|
'IndentLeft' => ['type' => 'int', 'null' => true, 'default' => 0],
|
|
'FontStyle' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
|
'VisibleScr' => ['type' => 'int', 'null' => true, 'default' => 1],
|
|
'VisibleRpt' => ['type' => 'int', 'null' => true, 'default' => 1],
|
|
'CountStat' => ['type' => 'int', 'null' => true, 'default' => 1],
|
|
'Level' => ['type' => 'int', 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('TestSiteID', true);
|
|
$this->forge->createTable('testdefsite');
|
|
|
|
// testdeftech table removed - merged into testdefsite
|
|
|
|
$this->forge->addField([
|
|
'TestCalID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'TestSiteID' => ['type' => 'INT', 'unsigned' => true, 'null' => false],
|
|
'DisciplineID' => ['type' => 'INT', 'null' => true],
|
|
'DepartmentID' => ['type' => 'INT', 'null' => true],
|
|
'FormulaInput' => ['type' => 'text', 'null' => true],
|
|
'FormulaCode' => ['type' => 'varchar', 'constraint'=> 255, 'null' => true],
|
|
'RefType' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true, 'default' => 'NMRC'],
|
|
'Unit1' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
|
'Factor' => ['type' => 'DECIMAL', 'constraint'=> '10,4', 'null' => true],
|
|
'Unit2' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
|
'Decimal' => ['type' => 'int', 'null' => true, 'default' => 2],
|
|
'Method' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('TestCalID', true);
|
|
$this->forge->addForeignKey('TestSiteID', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
|
$this->forge->createTable('testdefcal');
|
|
|
|
$this->forge->addField([
|
|
'TestGrpID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'TestSiteID' => ['type' => 'INT', 'unsigned' => true, 'null' => false],
|
|
'Member' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('TestGrpID', true);
|
|
$this->forge->addForeignKey('TestSiteID', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
|
$this->forge->addForeignKey('Member', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
|
$this->forge->createTable('testdefgrp');
|
|
|
|
$this->forge->addField([
|
|
'TestMapID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'TestSiteID' => ['type' => 'INT', 'unsigned' => true, 'null' => false],
|
|
'HostType' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
|
'HostID' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
|
'HostDataSource' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
|
'HostTestCode' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true],
|
|
'HostTestName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => true],
|
|
'ClientType' => ['type' => 'varchar', 'constraint'=> 20, 'null' => true],
|
|
'ClientID' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
|
'ClientDataSource' => ['type' => 'varchar', 'constraint'=> 50, 'null' => true],
|
|
'ConDefID' => ['type' => 'INT', 'null' => true],
|
|
'ClientTestCode' => ['type' => 'varchar', 'constraint'=> 10, 'null' => true],
|
|
'ClientTestName' => ['type' => 'varchar', 'constraint'=> 100, 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true]
|
|
]);
|
|
$this->forge->addKey('TestMapID', true);
|
|
$this->forge->addForeignKey('TestSiteID', 'testdefsite', 'TestSiteID', 'CASCADE', 'CASCADE');
|
|
$this->forge->createTable('testmap');
|
|
|
|
$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' => true],
|
|
'Sex' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Criteria' => ['type' => 'varchar', 'constraint'=>100, 'null' => true],
|
|
'AgeStart' => ['type' => 'INT', 'null' => true],
|
|
'AgeEnd' => ['type' => 'int', 'null' => true],
|
|
'NumRefType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'RangeType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'LowSign' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Low' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
|
|
'HighSign' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'High' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
|
|
'Display' => ['type' => 'INT', 'null' => true],
|
|
'Flag' => ['type' => 'varchar', 'constraint'=>10, 'null' => true],
|
|
'Interpretation' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
|
'Notes' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('RefNumID', true);
|
|
$this->forge->createTable('refnum');
|
|
|
|
$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' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'Criteria' => ['type' => 'varchar', 'constraint'=>100, 'null' => true],
|
|
'AgeStart' => ['type' => 'INT', 'null' => true],
|
|
'AgeEnd' => ['type' => 'int', 'null' => true],
|
|
'TxtRefType' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
|
|
'RefTxt' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
|
'Flag' => ['type' => 'varchar', 'constraint'=>10, 'null' => true],
|
|
'Notes' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
|
'CreateDate' => ['type' => 'Datetime', 'null' => true],
|
|
'StartDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('RefTxtID', true);
|
|
$this->forge->createTable('reftxt');
|
|
|
|
$this->forge->addField([
|
|
'FlagDefID' => ['type' => 'INT', 'auto_increment' => true],
|
|
'InstrumentName' => ['type' => 'varchar', 'constraint' => 100, 'null' => true],
|
|
'Flag' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
|
|
]);
|
|
$this->forge->addKey('FlagDefID', true);
|
|
$this->forge->createTable('flagdef');
|
|
}
|
|
|
|
public function down() {
|
|
$this->forge->dropTable('flagdef');
|
|
$this->forge->dropTable('reftxt');
|
|
$this->forge->dropTable('refnum');
|
|
$this->forge->dropTable('testmap');
|
|
$this->forge->dropTable('testdefgrp');
|
|
$this->forge->dropTable('testdefcal');
|
|
// testdeftech table removed - merged into testdefsite
|
|
$this->forge->dropTable('testdefsite');
|
|
}
|
|
}
|