update sku mapping
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user