Merge branch 'main' of ssh://gitlab.fcpays.cc:2222/root/coruna-lab
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 为数据分析页国家维度聚合与设备列表国家筛选添加复合索引。
|
||||
* 参考 os_version 维度的 (created_at, os, os_version) 复合索引做法,
|
||||
* 让按日期范围 + GROUP BY country 的聚合查询能走索引扫描。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('page_visits', function (Blueprint $table) {
|
||||
$table->index(['created_at', 'country'], 'page_visits_created_at_country_index');
|
||||
});
|
||||
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
$table->index(['created_at', 'country'], 'devices_created_at_country_index');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('page_visits', function (Blueprint $table) {
|
||||
$table->dropIndex('page_visits_created_at_country_index');
|
||||
});
|
||||
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
$table->dropIndex('devices_created_at_country_index');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user