clqms-be/app/Database/Migrations/2025-09-12-011643_Contact.php

65 lines
3.5 KiB
PHP
Raw Normal View History

2025-09-12 11:27:54 +07:00
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
2025-09-17 15:50:55 +07:00
class CreateContactTable extends Migration {
2025-09-12 11:27:54 +07:00
public function up() {
2025-09-17 15:50:55 +07:00
// Contact
2025-09-12 11:27:54 +07:00
$this->forge->addField([
2025-09-18 15:52:37 +07:00
'ContactID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
2025-09-12 11:27:54 +07:00
'NameFirst' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
'NameLast' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
'Title' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
'Initial' => [ 'type' => 'VARCHAR', 'constraint' => 10, 'null' => true ],
'Birthdate' => [ 'type' => 'DATE', 'null' => true ],
'EmailAddress1' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
'EmailAddress2' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
'Phone' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
'MobilePhone1' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
'MobilePhone2' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
'Specialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
'SubSpecialty' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
2025-09-26 15:03:11 +07:00
'CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
2025-09-12 11:27:54 +07:00
'EndDate' => [ 'type' => 'DATETIME', 'null' => true ],
]);
$this->forge->addKey('ContactID', true);
2025-09-17 15:50:55 +07:00
$this->forge->createTable('contact');
2025-09-12 11:27:54 +07:00
2025-09-17 15:50:55 +07:00
// ContactDetail
2025-09-12 11:27:54 +07:00
$this->forge->addField([
2025-09-22 13:25:31 +07:00
'ContactDetID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
'ContactID' => [ 'type' => 'INT', 'constraint' => 11 ],
'SiteID' => [ 'type' => 'INT', 'constraint' => 11, 'null' => true ],
'ContactCode' => [ 'type' => 'varchar', 'constraint' => 11, 'null' => false ],
'ContactEmail' => [ 'type' => 'VARCHAR', 'constraint' => 150, 'null' => true ],
'OccupationID' => [ 'type' => 'VARCHAR', 'constraint' => 50, 'null' => true ],
'JobTitle' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
'Department' => [ 'type' => 'VARCHAR', 'constraint' => 100, 'null' => true ],
2025-09-26 13:08:30 +07:00
'ContactStartDate' => [ 'type' => 'DATETIME', 'null' => true ],
2025-09-26 15:03:11 +07:00
'ContactEndDate' => [ 'type' => 'DATETIME ', 'null' => true ],
2025-09-12 11:27:54 +07:00
]);
$this->forge->addKey('ContactDetID', true);
2025-09-24 16:15:55 +07:00
$this->forge->addUniqueKey(['SiteID','ContactID']);
2025-09-17 15:50:55 +07:00
$this->forge->createTable('contactdetail');
2025-09-12 11:27:54 +07:00
2025-09-17 15:50:55 +07:00
// Occupation
$this->forge->addField([
'OccupationID' => [ 'type' => 'INT', 'constraint' => 11, 'auto_increment' => true],
'AbbTex' => [ 'type' => 'VARCHAR', 'constraint' => 5, 'null' => true ],
'FullText' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
'Description' => [ 'type' => 'TEXT', 'null' => true ],
2025-09-26 13:08:30 +07:00
'CreateDate' => [ 'type' => 'DATETIME', 'null' => true ],
2025-09-17 15:50:55 +07:00
]);
$this->forge->addKey('OccupationID', true);
$this->forge->createTable('occupation');
2025-09-12 11:27:54 +07:00
}
public function down() {
$this->forge->dropTable('Contact');
$this->forge->dropTable('ContactDetail');
2025-09-17 15:50:55 +07:00
$this->forge->dropTable('Occupation');
2025-09-12 11:27:54 +07:00
}
}