32 lines
1.2 KiB
PHP
32 lines
1.2 KiB
PHP
<?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');
|
||
}
|
||
}; |