forge->addField([ 'invoice_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], 'invoice_no' => ['type' => 'VARCHAR', 'constraint' => 255], 'invoice_type_id' => ['type' => 'INT', 'unsigned' => true], 'invoice_item_id' => ['type' => 'INT', 'unsigned' => true], 'invoice_date' => ['type' => 'DATETIME', 'null' => true], 'customer_id' => ['type' => 'INT', 'unsigned' => true], 'customer_phone_no' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], 'customer_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'salesman_no' => ['type' => 'VARCHAR', 'constraint' => 50, 'null' => true], 'salesman_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true], 'payment_method_id' => ['type' => 'INT', 'unsigned' => true], 'branch_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true], 'created_at' => ['type' => 'DATETIME', 'null' => true], 'updated_at' => ['type' => 'DATETIME', 'null' => true], 'deleted_at' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addKey('invoice_id', true); $this->forge->addForeignKey('invoice_type_id', 'invoice_type', 'invoice_type_id', 'CASCADE', 'CASCADE'); $this->forge->addForeignKey('invoice_item_id', 'invoice_item', 'invoice_item_id', 'CASCADE', 'CASCADE'); $this->forge->addForeignKey('customer_id', 'customer_details', 'customer_id', 'CASCADE', 'CASCADE'); $this->forge->addForeignKey('payment_method_id', 'payment_method', 'payment_method_id', 'CASCADE', 'CASCADE'); $this->forge->createTable('invoice'); } public function down() { $this->forge->dropTable('invoice'); } }