clqms-be/app/Database/Migrations/2026-01-01-000001_CreateValueSet.php

106 lines
4.8 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateLookups extends Migration {
public function up() {
$this->forge->addField([
'VID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'VSetID' => ['type' => 'INT', 'null' => true],
'VOrder' => ['type' => 'INT', 'null' => true],
'VValue' => ['type' => 'varchar', 'constraint' => 10],
'VDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'VCategory' => ['type' => 'int', 'null' => true],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addKey('VID', true);
$this->forge->createTable('valueset');
$this->forge->addField([
'VSetID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'VSName' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
'VSDesc' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addKey('VSetID', true);
$this->forge->createTable('valuesetdef');
$this->forge->addField([
'CounterID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'CounterValue' => ['type' => 'INT', 'null' => false],
'CounterStart' => ['type' => 'INT', 'null' => false],
'CounterEnd' => ['type' => 'INT', 'null' => false],
'CounterName' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true, 'after' => 'CounterID' ],
'CounterDesc' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'CounterReset' => ['type' => 'varchar', 'constraint' => 1, 'null' => true],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addKey('CounterID', true);
$this->forge->createTable('counter');
$this->forge->addField([
'ConDefID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'ConCode' => ['type' => 'VARCHAR', 'constraint' => 3, 'null' => false],
'ConName' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
'ConDesc' => ['type' => 'varchar', 'constraint' => 50, 'null' => true],
'Additive' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
'ConClass' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
'Color' => ['type' => 'VARCHAR', 'constraint' => 10, 'null' => true],
'CreateDate' => ['type' => 'Datetime', 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addKey('ConDefID', true);
$this->forge->addUniqueKey('ConCode');
$this->forge->createTable('containerdef');
$this->forge->addField([
'OccupationID' => [ 'type' => 'INT', 'constraint' => 11, 'auto_increment' => true],
'OccCode' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ],
'OccText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
'Description' => [ 'type' => 'TEXT', 'null' => true ],
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('OccupationID', true);
$this->forge->createTable('occupation');
$this->forge->addField([
'SpecialtyID' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'SpecialtyText' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'Parent' => ['type' => 'int', 'null' => true],
'Title' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
'CreateDate' => ['type' => 'datetime', 'null' => true],
'EndDate' => ['type' => 'datetime', 'null' => true],
]);
$this->forge->addKey('SpecialtyID', true);
$this->forge->createTable('medicalspecialty');
$this->forge->addField([
'AreaGeoID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'AreaCode' => ['type' => 'varchar', 'constraint' => 20, 'null' => true],
'Class' => ['type' => 'int', 'null' => true],
'AreaName' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => false],
'Parent' => ['type' => 'int', 'null' => true],
]);
$this->forge->addKey('AreaGeoID', true);
$this->forge->createTable('areageo');
}
public function down() {
$this->forge->dropTable('areageo');
$this->forge->dropTable('medicalspecialty');
$this->forge->dropTable('occupation');
$this->forge->dropTable('containerdef');
$this->forge->dropTable('counter');
$this->forge->dropTable('valuesetdef');
$this->forge->dropTable('valueset');
}
}