clqms-be/app/Database/Migrations/2025-09-02-070522_Patient_master.php

67 lines
2.9 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreatePatMasterTables extends Migration {
public function up() {
// country
$this->forge->addField([
'SiteID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'CodingSysID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'IntCountryID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'CountryID' => ['type' => 'VARCHAR', 'constraint' => 10],
'Country' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
$this->forge->addKey('IntCountryID', true);
$this->forge->addUniqueKey('CountryID');
$this->forge->createTable('country');
// ethnic
$this->forge->addField([
'SiteID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'CodingSysID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'EthnicID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'Ethnic' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
$this->forge->addKey('EthnicID', true);
$this->forge->createTable('ethnic');
// race
$this->forge->addField([
'SiteID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'CodingSysID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'RaceID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'Race' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
$this->forge->addKey('RaceID', true);
$this->forge->createTable('race');
// religion
$this->forge->addField([
'SiteID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'CodingSysID' => ['type' => 'INT', 'constraint' => 11, 'null' => true],
'ReligionID' => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'Religion' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
$this->forge->addKey('ReligionID', true);
$this->forge->createTable('religion');
}
public function down() {
$this->forge->dropTable('race', true);
$this->forge->dropTable('religion', true);
$this->forge->dropTable('country', true);
$this->forge->dropTable('ethnic', true);
}
}