add sku mapping

This commit is contained in:
2026-04-14 13:45:28 +08:00
parent b647680576
commit b1cd4ea0eb
16 changed files with 3176 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('skus_mapping', function (Blueprint $table) {
$table->bigInteger('origin_sku_id')->nullable()->comment('关联 skus_origin.idFK');
$table->text('platform_outer_sku')->nullable()->comment('平台侧使用的 SKU 编码');
$table->text('generation_strategy')->nullable()->comment('生成策略记录,如 prefix:C03、prefix_random:C03:4、manual');
$table->index(['company_id', 'origin_sku_id', 'platform_id'], 'idx_company_origin_platform');
$table->index(['platform_outer_sku', 'platform_id'], 'idx_outer_sku_platform');
$table->foreign('origin_sku_id')
->references('id')
->on('skus_origin')
->onDelete('restrict')
->onUpdate('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('skus_mapping', function (Blueprint $table) {
$table->dropForeign(['origin_sku_id']);
$table->dropIndex('idx_company_origin_platform');
$table->dropIndex('idx_outer_sku_platform');
$table->dropColumn(['origin_sku_id', 'platform_outer_sku', 'generation_strategy']);
});
}
};