66 lines
3.6 KiB
PHP
66 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateContactTable extends Migration {
|
|
public function up() {
|
|
// Contact
|
|
$this->forge->addField([
|
|
'ContactID' => [ 'type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true ],
|
|
'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 ],
|
|
'Password' => [ 'type' => 'VARCHAR', 'constraint' => 255, 'null' => true ],
|
|
'CreateDate' => ['type' => 'DATETIME', 'null' => true],
|
|
'EndDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
|
]);
|
|
$this->forge->addKey('ContactID', true);
|
|
$this->forge->createTable('contact');
|
|
|
|
// ContactDetail
|
|
$this->forge->addField([
|
|
'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 ],
|
|
'ContactStartDate' => [ 'type' => 'DATETIME', 'null' => true ],
|
|
'ContactEndDate' => [ 'type' => 'DATETIME ', 'null' => true ],
|
|
]);
|
|
$this->forge->addKey('ContactDetID', true);
|
|
$this->forge->addUniqueKey(['SiteID','ContactID']);
|
|
$this->forge->createTable('contactdetail');
|
|
|
|
// Occupation
|
|
$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');
|
|
}
|
|
|
|
public function down() {
|
|
$this->forge->dropTable('Contact');
|
|
$this->forge->dropTable('ContactDetail');
|
|
$this->forge->dropTable('Occupation');
|
|
}
|
|
}
|