AMS_Backend/app/Database/Migrations/2025-11-05-031045_CreateBranchDetails.php
2025-11-06 13:41:06 +08:00

44 lines
2.2 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateBranchDetails extends Migration
{
public function up()
{
$this->forge->addField([
'branch_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'branch_name' => ['type' => 'VARCHAR', 'constraint' => 255],
'branch_category_id' => ['type' => 'INT', 'unsigned' => true],
'branch_bank' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'branch_bank_no' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'agreement_start' => ['type' => 'DATE', 'null' => true],
'agreement_end' => ['type' => 'DATE', 'null' => true],
'liscense_one' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'liscense_one_end' => ['type' => 'DATE', 'null' => true],
'liscense_two' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'liscense_two_end' => ['type' => 'DATE', 'null' => true],
'liscense_three' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
'liscense_three_end' => ['type' => 'DATE', 'null' => true],
'invoice_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
'letterhead_id' => ['type' => 'INT', 'unsigned' => true],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('branch_id', true);
$this->forge->addForeignKey('branch_category_id', 'branch_category', 'branch_category_id', 'CASCADE', 'CASCADE');
$this->forge->addForeignKey('invoice_id', 'invoice', 'invoice_id', 'SET NULL', 'CASCADE');
$this->forge->addForeignKey('letterhead_id', 'letterhead', 'letterhead_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('branch_details');
}
public function down()
{
$this->forge->dropTable('branch_details');
}
}