67 lines
2.8 KiB
PHP
67 lines
2.8 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],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$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],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$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],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$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],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'EndDate' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$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);
|
|
}
|
|
}
|