29 lines
1.3 KiB
TypeScript
29 lines
1.3 KiB
TypeScript
import type { Migration, Sql } from '@/shared/db';
|
|
|
|
export const providerGradesMigrations: readonly Migration[] = [
|
|
{
|
|
id: '2026-05-17_provider_market_grades_initial',
|
|
async up(sql: Sql): Promise<void> {
|
|
// Per-provider, per-category letter grade. The clearance test against a
|
|
// destination's market_min_grades JSONB drives opportunity ranking.
|
|
//
|
|
// category is open-ended (TS-validated against PROVIDER_CATEGORIES) so we
|
|
// can introduce new niches (bbw, mature, gfe, ...) without DB migrations.
|
|
// 'overall' is the headline; 'general' / 'trans' / niche grades drive math.
|
|
//
|
|
// grade is validated app-side against rubric.ts:GRADES — a CHECK constraint
|
|
// here would duplicate the source of truth and drift.
|
|
await sql`
|
|
CREATE TABLE IF NOT EXISTS provider_market_grades (
|
|
provider_slug TEXT NOT NULL,
|
|
category TEXT NOT NULL,
|
|
grade TEXT NOT NULL,
|
|
rubric_notes TEXT,
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (provider_slug, category)
|
|
)
|
|
`;
|
|
await sql`CREATE INDEX IF NOT EXISTS idx_provider_market_grades_provider ON provider_market_grades(provider_slug)`;
|
|
},
|
|
},
|
|
];
|