The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(db, docs): prep to sync troubleshooting entries to github (#29824)
Charisc8ed6e4cc1d1
diff --git a/apps/docs/app/guides/troubleshooting/page.tsx b/apps/docs/app/guides/troubleshooting/page.tsxindex e5e96fe66df..587e84fa1ae 100644--- a/apps/docs/app/guides/troubleshooting/page.tsx+++ b/apps/docs/app/guides/troubleshooting/page.tsx@@ -23,7 +23,7 @@ export default async function GlobalTroubleshootingPage() {const errors = await getAllTroubleshootingErrors()return (- <SidebarSkeleton className="w-full max-w-screen-lg mx-auto">+ <SidebarSkeleton hideSideNav className="w-full max-w-screen-lg mx-auto"><div className="py-8 px-5"><h1 className="text-4xl tracking-tight mb-7">Troubleshooting</h1><p className="text-lg text-foreground-light">diff --git a/apps/docs/features/docs/Troubleshooting.page.tsx b/apps/docs/features/docs/Troubleshooting.page.tsxindex a7032716e1a..5acc242328c 100644--- a/apps/docs/features/docs/Troubleshooting.page.tsx+++ b/apps/docs/features/docs/Troubleshooting.page.tsx@@ -10,12 +10,19 @@ import { formatError, serializeTroubleshootingSearchParams } from './Troubleshooexport default function TroubleshootingPage({ entry }: { entry: ITroubleshootingEntry }) {return (- <SidebarSkeleton className="@container/troubleshooting-entry-layout w-full max-w-screen-lg mx-auto lg:py-8 lg:px-5">+ <SidebarSkeleton+ hideSideNav+ className="@container/troubleshooting-entry-layout w-full max-w-screen-lg mx-auto lg:py-8 lg:px-5"+ ><div className="px-5 py-8 lg:px-0 lg:py-0"><Breadcrumbs minLength={1} forceDisplayOnMobile /><article className="prose max-w-none mt-4"><h1>{entry.data.title}</h1>- {entry.data.updated_at && <p>Last edited: {entry.data.updated_at.toLocaleString()}</p>}+ {entry.data.updated_at && (+ <p className="text-sm text-foreground-lighter">+ Last edited: {entry.data.updated_at.toLocaleString()}+ </p>+ )}<hr className="my-7" aria-hidden /><div className="grid gap-10 @3xl/troubleshooting-entry-layout:grid-cols-[1fr,250px]"><div>diff --git a/apps/docs/features/docs/Troubleshooting.ui.tsx b/apps/docs/features/docs/Troubleshooting.ui.tsxindex 9c7502f74f6..06ca618cff2 100644--- a/apps/docs/features/docs/Troubleshooting.ui.tsx+++ b/apps/docs/features/docs/Troubleshooting.ui.tsx@@ -26,7 +26,7 @@ export function TroubleshootingPreview({ entry }: { entry: ITroubleshootingEntry{...attributes}><div className="flex flex-wrap items-start gap-x-2 gap-y-4 justify-between">- <div className="w-full flex flex-col gap-2">+ <div className="flex-grow flex flex-col gap-2"><Linkhref={`/guides/troubleshooting/${getArticleSlug(entry.data)}`}className={cn('visited:text-foreground-lighter', 'before:absolute before:inset-0')}diff --git a/supabase/migrations/20241002215612_troubleshooting_validation.sql b/supabase/migrations/20241002215612_troubleshooting_validation.sqlnew file mode 100644index 00000000000..5bf2a1118c1--- /dev/null+++ b/supabase/migrations/20241002215612_troubleshooting_validation.sql@@ -0,0 +1,74 @@+alter table troubleshooting_entries+add column github_id text not null;++alter table troubleshooting_entries+add column checksum text not null;++create index idx_troubleshooting_checksum+on troubleshooting_entries (checksum);++create extension pg_jsonschema;++alter table troubleshooting_entries+add constraint troubleshooting_api_check+check (+ api is null or+ jsonb_matches_schema(+ schema := '{+ "type": "object",+ "properties": {+ "sdk": {+ "type": "array",+ "items": { "type": "string" }+ },+ "management_api": {+ "type": "array",+ "items": { "type": "string" }+ },+ "cli": {+ "type": "array",+ "items": { "type": "string" }+ }+ },+ "additionalProperties": false+ }',+ instance := api+ )+);++create or replace function validate_troubleshooting_errors(errors jsonb[])+returns boolean as $$+declare+ error jsonb;+begin+ if errors is null then+ return true;+ end if;++ foreach error in array errors+ loop+ if not jsonb_matches_schema(+ schema := '{+ "type": "object",+ "properties": {+ "http_status_code": { "type": "number" },+ "code": { "type": "string" },+ "message": { "type": "string" }+ },+ "additionalProperties": false+ }',+ instance := error+ ) then+ return false;+ end if;+ end loop;++ return true;+end;+$$ language plpgsql;++alter table troubleshooting_entries+add constraint troubleshooting_errors_check+check (+ validate_troubleshooting_errors(errors)+);