Files
datahub/backend/migrations/2026_05_07_100000_enable_timescaledb_extension.php
nz 785726caac add timescaledb extension migration and orders_daily_by_created continuous aggregate
P22.1 of Stage 22 materialization layer infrastructure. Adds explicit
CREATE EXTENSION migration so clean environments can run `migrate` end-to-end
without ops manual setup, then creates the first continuous aggregate
orders_daily_by_created (day-bucketed, grouped by company/platform/store)
with WITH NO DATA. Five composite indexes cover the high-frequency query
patterns documented in docs/data_query.md. P22.2/P22.3 will add the
by-paid view, refresh policy and historical backfill on top.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 12:07:17 +08:00

21 lines
491 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
use Hyperf\DbConnection\Db;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
public function up(): void
{
Db::statement('CREATE EXTENSION IF NOT EXISTS timescaledb');
}
public function down(): void
{
// 不主动 DROP EXTENSIONexisting hypertables 依赖该扩展,drop 会破坏数据。
// 完全清空数据库时手动执行 `DROP EXTENSION timescaledb CASCADE`。
}
};