clqms-be/app/Database/Migrations/2025-09-10-141522_Location.php
2025-09-19 15:22:25 +07:00

44 lines
2.0 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateLocationTable extends Migration {
public function up() {
$this->forge->addField([
'LocationID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'SiteID' => ['type' => 'INT', 'null' => true],
'LocCode' => ['type' => 'VARCHAR', 'constraint' => 6, 'null' => false],
'Parent' => ['type' => 'INT', 'null' => true],
'LocFull' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'Description' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'LocType' => ['type' => 'varchar', 'constraint' => 11, 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
$this->forge->addKey('LocationID', true);
$this->forge->createTable('location');
$this->forge->addField([
'LocationID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
'Street1' => ['type' => 'Varchar', 'constraint' => 255, 'null' => true],
'Street2' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => false],
'City' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'Province' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'PostCode' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'GeoLocationSystem' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'GeoLocationData' => ['type' => 'varchar', 'constraint' => 255, 'null' => true],
'EndDate' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
$this->forge->addKey('LocationID', true);
$this->forge->createTable('locationaddress');
}
public function down() {
$this->forge->dropTable('location');
$this->forge->dropTable('locationaddress');
}
}