40 lines
2.0 KiB
PHP
40 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class CreateProduct extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addField([
|
|
'product_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
|
|
'model_no' => ['type' => 'VARCHAR', 'constraint' => '255'],
|
|
'product_brand_id' => ['type' => 'INT', 'unsigned' => true],
|
|
'product_category_id' => ['type' => 'INT', 'unsigned' => true],
|
|
'product_description_id'=> ['type' => 'INT', 'unsigned' => true],
|
|
'siri_no_sequence' => ['type' => 'VARCHAR', 'constraint' => '255', 'null' => true],
|
|
'product_imei_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
|
'supplier_id' => ['type' => 'INT', 'unsigned' => true],
|
|
'selling_price' => ['type' => 'DECIMAL', 'constraint' => '10,2', 'null' => true],
|
|
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'updated_at' => ['type' => 'DATETIME', 'null' => true],
|
|
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
|
|
]);
|
|
$this->forge->addKey('product_id', true);
|
|
$this->forge->addForeignKey('product_brand_id', 'product_brand', 'product_brand_id', 'CASCADE', 'CASCADE');
|
|
$this->forge->addForeignKey('product_category_id', 'product_category', 'product_category_id', 'CASCADE', 'CASCADE');
|
|
$this->forge->addForeignKey('product_description_id', 'product_description', 'product_description_id', 'CASCADE', 'CASCADE');
|
|
$this->forge->addForeignKey('product_imei_id', 'product_imei', 'product_imei_id', 'SET NULL', 'CASCADE');
|
|
$this->forge->addForeignKey('supplier_id', 'supplier_details', 'supplier_id', 'CASCADE', 'CASCADE');
|
|
$this->forge->createTable('product');
|
|
}
|
|
|
|
|
|
public function down()
|
|
{
|
|
$this->forge->dropTable('product');
|
|
}
|
|
}
|