update sku mapping

This commit is contained in:
2026-04-14 15:45:29 +08:00
parent b1cd4ea0eb
commit 417ac5e1f9
11 changed files with 1454 additions and 75 deletions
@@ -0,0 +1,43 @@
<?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->text('platform_product_id')->nullable()->change();
});
// 删除原有唯一约束(如果存在)并创建部分唯一索引
$connection = Schema::getConnection();
$connection->statement('DROP INDEX IF EXISTS uk_platform_product');
$connection->statement(
'CREATE UNIQUE INDEX uk_platform_product ON skus_mapping (platform_id, platform_product_id) WHERE platform_product_id IS NOT NULL'
);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$connection = Schema::getConnection();
$connection->statement('DROP INDEX IF EXISTS uk_platform_product');
$connection->statement(
'CREATE UNIQUE INDEX uk_platform_product ON skus_mapping (platform_id, platform_product_id)'
);
Schema::table('skus_mapping', function (Blueprint $table) {
$table->text('platform_product_id')->nullable(false)->change();
});
}
};