update store table

This commit is contained in:
2025-12-03 16:01:55 +08:00
parent 2c32a0c0af
commit db4824b776
2 changed files with 52 additions and 0 deletions
@@ -0,0 +1,46 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
use Hyperf\DbConnection\Db;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('stores', function (Blueprint $table) {
// 在 platform_store_id 后添加 platform_meta 字段
$table->jsonb('platform_meta')
->nullable()
->after('platform_store_id')
->comment('平台店铺扩展信息 如 店铺所属服务商 - 平台应用 id - 平台商家 id, 平台店铺名称-区域 等根据需要补充其他额外信息');
// 在 platform_meta 后添加 timezone 字段
$table->tinyInteger('timezone')
->default(8)
->after('platform_meta')
->comment('平台店铺统计时使用的时区 默认为 +8 表示 北京时间, 如果是日本则是 +7, 填写基于 UTC 的偏移值');
});
// 为 platform_meta JSONB 字段创建 GIN 索引,支持高效的 JSON 查询
Db::statement('CREATE INDEX idx_stores_platform_meta ON stores USING GIN (platform_meta)');
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// 删除 GIN 索引
Db::statement('DROP INDEX IF EXISTS idx_stores_platform_meta');
Schema::table('stores', function (Blueprint $table) {
// 删除添加的字段
$table->dropColumn(['platform_meta', 'timezone']);
});
}
};