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

30 lines
914 B
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateStock extends Migration
{
public function up()
{
$this->forge->addField([
'stock_id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'product_id' => ['type' => 'INT', 'unsigned' => true],
'stock_qty' => ['type' => 'INT', 'default' => 0],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addKey('stock_id', true);
$this->forge->addForeignKey('product_id', 'product', 'product_id', 'CASCADE', 'CASCADE');
$this->forge->createTable('stock');
}
public function down()
{
$this->forge->dropTable('stock');
}
}