erp-backend/database/migrations/2026_03_13_103634_create_goods_table.php
2026-04-01 17:07:04 +08:00

32 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('goods', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code')->unique()->comment('商品编码SKU');
$table->string('barcode')->nullable()->comment('商品条码');
$table->string('category')->nullable()->comment('分类 food/clothing/electronics');
$table->string('unit', 20)->comment('单位');
$table->decimal('weight', 10, 2)->default(0)->comment('重量(克)');
$table->decimal('retail_price', 10, 2)->comment('零售价');
$table->decimal('cost_price', 10, 2)->comment('成本价');
$table->integer('stock_warning')->default(0)->comment('库存预警阈值');
$table->enum('type', ['normal', 'combo'])->default('normal')->comment('商品类型');
$table->timestamps();
$table->softDeletes(); // 可选,如果需要软删除
});
}
public function down(): void
{
Schema::dropIfExists('goods');
}
};