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
+6
View File
@@ -11,6 +11,8 @@ use Hyperf\DbConnection\Model\Model;
* @property int $company_id 店铺所属的公司 ID
* @property int $platform_id 平台 ID
* @property string $platform_store_id 平台店铺 ID
* @property array $platform_meta 平台店铺扩展信息 如 店铺所属服务商 - 平台应用 id - 平台商家 id, 平台店铺名称-区域 等根据需要补充其他额外信息
* @property int $timezone 平台店铺统计时使用的时区 默认为 +8 表示 北京时间, 如果是日本则是 +7, 填写基于 UTC 的偏移值
* @property int $warehouse_id 店铺使用的仓库 ID
* @property int $currency_id 店铺的本币 ID
* @property boolean $enabled 激活状态
@@ -41,6 +43,8 @@ class Store extends Model
'company_id',
'platform_id',
'platform_store_id',
'platform_meta',
'timezone',
'warehouse_id',
'currency_id',
'enabled',
@@ -58,6 +62,8 @@ class Store extends Model
'id' => 'integer',
'company_id' => 'integer',
'platform_id' => 'integer',
'platform_meta' => 'array',
'timezone' => 'integer',
'warehouse_id' => 'integer',
'currency_id' => 'integer',
'enabled' => 'boolean',
@@ -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']);
});
}
};