feat(db): seed suppliers.code='direct' for DIRECT platform billing

LedgerService::resolveSupplierId will look up suppliers WHERE code='direct'
for DIRECT-platform supplier_projects (Phase 3). cost_rub matches B1 (same
supplier company, different lead-routing channel).

Spec: docs/superpowers/specs/2026-05-25-supplier-webhook-reliability-design.md

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-05-25 17:18:16 +03:00
parent 1cf4c53d8d
commit 7ffd79299f
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* Phase 3 DIRECT supplier row (used by LedgerService::resolveSupplierId
* fallback for platform='DIRECT'). cost_rub matches B1 (same supplier,
* different routing).
*
* Spec: docs/superpowers/specs/2026-05-25-supplier-webhook-reliability-design.md §3 Phase 3
*/
return new class extends Migration
{
public function up(): void
{
$b1 = DB::table('suppliers')->where('code', 'b1')->first();
if ($b1 === null) {
// Если B1 нет — significant prod drift, не должно произойти.
// Создаём с дефолтным cost_rub=1.00 (как на prod 25.05.2026).
$costRub = '1.00';
} else {
$costRub = (string) $b1->cost_rub;
}
DB::table('suppliers')->updateOrInsert(
['code' => 'direct'],
[
'name' => 'DIRECT — Прямые проекты',
'cost_rub' => $costRub,
]
);
}
public function down(): void
{
DB::table('suppliers')->where('code', 'direct')->delete();
}
};