comment('存储 业务侧 SKU 到 客户原始 SKU 的映射信息, 当平台绑定异常时使用'); $table->bigIncrements('id')->primary()->comment('主键'); $table->integer('company_id')->comment('公司 ID 与 Tools 保持一致'); $table->integer('platform_id')->comment('平台 ID 与 Tools 保持一致'); $table->text('platform_product_id')->comment('平台 商品 ID 与 电商平台 保持一致'); $table->text('origin_sku')->comment('客户侧匹配的 SKU 编码, 组合商品需要拆分'); $table->integer('store_id')->nullable()->comment('店铺 ID 与 Tools 保持一致, 建议填写以方便核对'); $table->integer('warehouse_id')->nullable()->comment('店铺绑定仓库 ID 与 Tools 保持一致,建议填写,建议填写以方便核对'); $table->boolean('enabled')->default(true)->comment('是否启用映射规则,默认为启用'); $table->text('note')->nullable()->default(null)->comment('备注信息'); $table->timestampsTz(); // 创建联合唯一索引:确保同一平台的同一产品只能有一条映射记录 // 原始 SKU 的约束由业务侧实现 $table->unique(['platform_id', 'platform_product_id'], 'uk_platform_product'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('skus_mapping'); } };