37 lines
1.2 KiB
PHP
37 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
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
* 小程序购物车(门店订货车):按门店归属,同商品唯一行、加购合并累加
|
|
*/
|
|
public function up(): void
|
|
{
|
|
if (! Schema::hasTable('cart')) {
|
|
Schema::create('cart', function (Blueprint $table) {
|
|
$table->increments('id')->comment('购物车项ID');
|
|
$table->integer('store_id')->comment('门店ID(购物车归属者)');
|
|
$table->integer('product_id')->comment('商品ID');
|
|
$table->decimal('quantity', 10, 2)->default(0)->comment('订货量');
|
|
$table->timestamps();
|
|
$table->unique(['store_id', 'product_id'], 'cart_store_product_unique');
|
|
$table->index(['store_id', 'created_at'], 'cart_store_created_index');
|
|
$table->comment('小程序购物车表(门店订货车)');
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('cart');
|
|
}
|
|
};
|