76 lines
3.4 KiB
PHP
76 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateOrdersTable extends Migration {
|
|
public function up() {
|
|
$this->forge->addField([
|
|
'InternalOID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'OrderID' => ['type' => 'VARCHAR', 'constraint'=> 22, 'null' => false],
|
|
'PlacerID' => ['type' => 'VARCHAR', 'constraint'=> 22, 'null' => true],
|
|
'InternalPID' => ['type' => 'INT', 'null' => false],
|
|
'SiteID' => ['type' => 'VARCHAR', 'constraint'=> 15, 'null' => false],
|
|
'PVADTID' => ['type' => 'INT', 'null' => false],
|
|
'ReqApp' => ['type' => 'VARCHAR', 'constraint'=> 15, 'null' => true],
|
|
'LocationID' => ['type' => 'INT', 'null' => false],
|
|
'Priority' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true],
|
|
'TrnDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EffDate' => ['type' => 'Datetime', 'null' => true],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'Datetime', 'null' => true],
|
|
'DelDate' => ['type' => 'Datetime', 'null' => true]
|
|
]);
|
|
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
$this->forge->addKey('InternalOID', true);
|
|
$this->forge->addUniqueKey('OrderID');
|
|
$this->forge->createTable('ordertest');
|
|
|
|
$this->forge->addField([
|
|
'InternalOID' => ['type' => 'INT', 'null' => false],
|
|
'OrderComID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'Comment' => ['type' => 'text', 'null' => true],
|
|
'UserID' => ['type' => 'INT', 'null' => false],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'Datetime', 'null' => true],
|
|
'DelDate' => ['type' => 'Datetime', 'null' => true]
|
|
]);
|
|
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
$this->forge->addKey('OrderComID', true);
|
|
$this->forge->createTable('ordercom');
|
|
|
|
$this->forge->addField([
|
|
'InternalOID' => ['type' => 'INT', 'null' => false],
|
|
'OrderAttID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'Address' => ['type' => 'varchar', 'constraint'=>255, 'null' => true],
|
|
'UserID' => ['type' => 'INT', 'null' => false],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'Datetime', 'null' => true],
|
|
'DelDate' => ['type' => 'Datetime', 'null' => true]
|
|
]);
|
|
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
$this->forge->addKey('OrderAttID', true);
|
|
$this->forge->createTable('orderatt');
|
|
|
|
$this->forge->addField([
|
|
'InternalOID' => ['type' => 'INT', 'null' => false],
|
|
'OrderStatID' => ['type' => 'INT', 'auto_increment' => true, 'unsigned' => true],
|
|
'OrderStatus' => ['type' => 'varchar', 'constraint'=>2, 'null' => false],
|
|
'EndDate' => ['type' => 'Datetime', 'null' => true],
|
|
'ArchiveDate' => ['type' => 'Datetime', 'null' => true],
|
|
'DelDate' => ['type' => 'Datetime', 'null' => true]
|
|
]);
|
|
$this->forge->addField('CreateDate DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP');
|
|
$this->forge->addKey('OrderStatID', true);
|
|
$this->forge->createTable('orderstatus');
|
|
|
|
}
|
|
|
|
public function down() {
|
|
$this->forge->dropTable('ordertest');
|
|
$this->forge->dropTable('ordercom');
|
|
$this->forge->dropTable('orderatt');
|
|
$this->forge->dropTable('orderstatus');
|
|
}
|
|
} |