Ship production optimization M1-M12.5A: queues, metrics, HTTP observability, and vector search reliability.
Keep similar-ai from tripping the global circuit on a lone URL 502, clamp Qdrant search to 100, and add Server-Timing plus slow-request logging. Studio shared props, Academy S3 exists caching, heat chunking, and Redis/scheduler hygiene stay in this rollout.
This commit is contained in:
+71
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* M10 — proposed production schema change. Do not run on production until
|
||||
* a dedicated deploy window. idx_artwork_bucket is an exact duplicate of
|
||||
* UNIQUE uq_artwork_bucket (artwork_id, bucket_hour).
|
||||
*
|
||||
* idx_bucket_hour is a left prefix of idx_bucket_artwork and is documented
|
||||
* as a later candidate only — not dropped here.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('artwork_metric_snapshots_hourly')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $this->indexExists('artwork_metric_snapshots_hourly', 'idx_artwork_bucket')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('artwork_metric_snapshots_hourly', function (Blueprint $table) {
|
||||
$table->dropIndex('idx_artwork_bucket');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('artwork_metric_snapshots_hourly')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->indexExists('artwork_metric_snapshots_hourly', 'idx_artwork_bucket')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('artwork_metric_snapshots_hourly', function (Blueprint $table) {
|
||||
$table->index(['artwork_id', 'bucket_hour'], 'idx_artwork_bucket');
|
||||
});
|
||||
}
|
||||
|
||||
private function indexExists(string $table, string $indexName): bool
|
||||
{
|
||||
if (DB::getDriverName() === 'sqlite') {
|
||||
$indexes = DB::select("PRAGMA index_list({$table})");
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
if (($index->name ?? '') === $indexName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$database = Schema::getConnection()->getDatabaseName();
|
||||
$row = DB::selectOne(
|
||||
'SELECT COUNT(*) AS c FROM information_schema.statistics
|
||||
WHERE table_schema = ? AND table_name = ? AND index_name = ?',
|
||||
[$database, $table, $indexName]
|
||||
);
|
||||
|
||||
return (int) ($row->c ?? 0) > 0;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user