Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/docs/app/guides/(with-sidebar)/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '~/features/docs/GuidesMdx.utils'
import { GuideTemplate } from '~/features/docs/GuidesMdx.template'

// Serve 404 when accessing pages that aren't prebuilt
export const dynamicParams = false

type Params = { slug: string[] }
Expand Down
54 changes: 45 additions & 9 deletions apps/docs/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type Metadata, type ResolvingMetadata } from 'next'
import Link from 'next/link'
import { IconBackground, TextLink } from 'ui'
import { cn, IconBackground, TextLink } from 'ui'
import { IconPanel } from 'ui-patterns/IconPanel'

import MenuIconPicker from '~/components/Navigation/NavigationMenu/MenuIconPicker'
Expand Down Expand Up @@ -29,6 +29,7 @@ const products = [
href: '/guides/database/overview',
description:
'Supabase provides a full Postgres database for every project with Realtime functionality, database backups, extensions, and more.',
span: 'col-span-12 md:col-span-6',
},
{
title: 'Auth',
Expand All @@ -37,6 +38,7 @@ const products = [
href: '/guides/auth',
description:
'Add and manage email and password, passwordless, OAuth, and mobile logins to your project through a suite of identity providers and APIs.',
span: 'col-span-12 md:col-span-6',
},
{
title: 'Storage',
Expand All @@ -46,13 +48,6 @@ const products = [
description:
'Store, organize, transform, and serve large files—fully integrated with your Postgres database with Row Level Security access policies.',
},
{
title: 'AI & Vectors',
icon: 'ai',
hasLightIcon: true,
href: '/guides/ai',
description: 'Use Supabase to store and search embedding vectors.',
},
{
title: 'Realtime',
icon: 'realtime',
Expand All @@ -71,6 +66,27 @@ const products = [
},
]

const postgresIntegrations = [
{
title: 'AI & Vectors',
icon: 'ai',
href: '/guides/ai',
description: 'AI toolkit to manage embeddings',
},
{
title: 'Cron',
icon: 'cron',
href: '/guides/cron',
description: 'Schedule and monitor recurring Jobs',
},
// {
// title: 'Queues',
// icon: 'queue',
// href: '/guides/queue',
// description: 'Postgres-native pull queues',
// },
]

const selfHostingOptions = [
{
title: 'Auth',
Expand Down Expand Up @@ -161,7 +177,7 @@ const HomePage = () => (
<ul className="grid grid-cols-12 gap-6 not-prose [&_svg]:text-brand-600">
{products.map((product) => {
return (
<li key={product.title} className="col-span-12 md:col-span-4">
<li key={product.title} className={cn(product.span ?? 'col-span-12 md:col-span-4')}>
<Link href={product.href} passHref>
<GlassPanelWithIconPicker {...product}>
{product.description}
Expand All @@ -172,6 +188,26 @@ const HomePage = () => (
})}
</ul>

<div className="flex flex-col lg:grid grid-cols-12 gap-6 py-12 border-b">
<div className="col-span-4">
<h2 id="postgres-integrations" className="scroll-mt-24 m-0">
Postgres Modules
</h2>
</div>
<div className="grid col-span-8 grid-cols-12 gap-6 not-prose">
{postgresIntegrations.map((integration) => (
<Link
href={integration.href}
key={integration.title}
passHref
className="col-span-6 md:col-span-4"
>
<IconPanelWithIconPicker {...integration} />
</Link>
))}
</div>
</div>

<div className="flex flex-col lg:grid grid-cols-12 gap-6 py-12 border-b">
<div className="col-span-4 flex flex-col gap-1 [&_h2]:m-0 [&_h3]:m-0">
<div className="md:max-w-xs 2xl:max-w-none">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Heart, Server } from 'lucide-react'
import { Clock, Heart, Server, SquareStack } from 'lucide-react'

import {
IconBranching,
Expand Down Expand Up @@ -93,6 +93,10 @@ function getMenuIcon(menuKey: string, width: number = 16, height: number = 16, c
return <Heart width={width} height={height} className={className} />
case 'deployment':
return <Server width={width} height={height} className={className} />
case 'cron':
return <Clock width={width} height={height} className={className} />
case 'queue':
return <SquareStack width={width} height={height} className={className} />
default:
return <IconMenuPlatform width={width} height={height} className={className} />
}
Expand Down
4 changes: 2 additions & 2 deletions apps/docs/components/Navigation/NavigationMenu/MenuIcons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { products } from 'shared-data'
import { PRODUCT_MODULES, products } from 'shared-data'

type HomeMenuIcon = {
width?: number
Expand Down Expand Up @@ -450,7 +450,7 @@ export function IconMenuAI({ width = 16, height = 16, className }: HomeMenuIcon)
xmlns="http://www.w3.org/2000/svg"
>
<path
d={products.vector.icon[16]}
d={PRODUCT_MODULES.vector.icon[16]}
stroke="currentColor"
strokeMiterlimit="10"
strokeLinecap="round"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,27 @@ export const GLOBAL_MENU_ITEMS: GlobalMenuItems = [
href: '/guides/realtime',
level: 'realtime',
},
],
[
{ label: 'Postgres Modules' },
{
label: 'AI & Vectors',
icon: 'ai',
href: '/guides/ai',
level: 'ai',
},
{
label: 'Cron',
icon: 'cron',
href: '/guides/cron',
level: 'cron',
},
// {
// label: 'Queues',
// icon: 'queue',
// href: '/guides/queues',
// level: 'queue',
// },
],
],
},
Expand Down Expand Up @@ -962,7 +977,7 @@ export const database: NavMenuConstant = {
url: '/guides/database/extensions/pgrouting',
},
{
name: 'pg_cron: Job Scheduling',
name: 'pg_cron: Schedule Recurring Jobs',
url: '/guides/database/extensions/pg_cron',
},
{
Expand Down Expand Up @@ -1114,6 +1129,23 @@ export const database: NavMenuConstant = {
],
}

export const cron: NavMenuConstant = {
icon: 'cron',
title: 'Cron',
url: '/guides/cron',
items: [
{ name: 'Overview', url: '/guides/cron' },
{
name: 'Getting Started',
url: undefined,
items: [
{ name: 'Install', url: '/guides/cron/install' },
{ name: 'Quickstart', url: '/guides/cron/quickstart' },
],
},
],
}

export const api: NavMenuConstant = {
icon: 'rest',
title: 'REST API',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum MenuId {
Realtime = 'realtime',
Storage = 'storage',
Ai = 'ai',
Cron = 'cron',
Platform = 'platform',
Deployment = 'deployment',
MonitoringTroubleshooting = 'monitoring_troubleshooting',
Expand Down Expand Up @@ -101,6 +102,7 @@ const menus: Menu[] = [
id: MenuId.Ai,
type: 'guide',
},
{ id: MenuId.Cron, type: 'guide' },
{
id: MenuId.Platform,
type: 'guide',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export const getMenuId = (pathname: string | null) => {
return MenuId.Api
case pathname.startsWith('auth'):
return MenuId.Auth
case pathname.startsWith('local-development'):
return MenuId.LocalDevelopment
case pathname.startsWith('cron'):
return MenuId.Cron
case pathname.startsWith('database'):
return MenuId.Database
case pathname.startsWith('deployment'):
Expand All @@ -123,6 +123,8 @@ export const getMenuId = (pathname: string | null) => {
return MenuId.Graphql
case pathname.startsWith('integrations'):
return MenuId.Integrations
case pathname.startsWith('local-development'):
return MenuId.LocalDevelopment
case pathname.startsWith('monitoring-troubleshooting'):
return MenuId.MonitoringTroubleshooting
case pathname.startsWith('platform'):
Expand Down
34 changes: 34 additions & 0 deletions apps/docs/content/guides/cron.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: 'Cron'
subtitle: 'Schedule Recurring Jobs with Cron Syntax in Postgres'
---

Supabase Cron is a Postgres Module that simplifies scheduling recurring Jobs with cron syntax and monitoring Job runs inside Postgres.

Cron Jobs can be created via SQL or the Cron interface inside of Supabase Dashboard and can run anywhere from every second to once a year depending on your use case.

Every Job can run SQL snippets or database functions with zero network latency or make an HTTP request, such as invoking a Supabase Edge Function, with ease.

<Admonition type="note">

For best performance, we recommend no more than 8 Jobs run concurrently. Each Job should run no more than 10 minutes.

</Admonition>

## How does Cron work?

Under the hood, Supabase Cron uses the [`pg_cron`](https://github.com/citusdata/pg_cron) Postgres database extension which is the scheduling and execution engine for your Jobs.

<Admonition type="note">

`pg_cron` is not fully supported on Fly Postgres. Learn more about [Fly Postgres limitations](/docs/guides/platform/fly-postgres#limitations).

</Admonition>

The extension creates a `cron` schema in your database and all Jobs are stored on the `cron.job` table. Every Job's run and its status is recorded on the `cron.job_run_details` table.

The Supabase Dashboard provides and interface for you to schedule Jobs and monitor Job runs. You can also do the same with SQL.

## Resources

- [`pg_cron` GitHub Repository](https://github.com/citusdata/pg_cron)
44 changes: 44 additions & 0 deletions apps/docs/content/guides/cron/install.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: 'Install'
---

Install the Supabase Cron Postgres Module to begin scheduling recurring Jobs.

<Tabs
scrollable
size="small"
type="underlined"
defaultActiveId="dashboard"
queryGroup="database-method"
>
<TabPanel id="dashboard" label="Dashboard">

1. Go to the [Cron Postgres Module](/dashboard/project/_/integrations/cron/overview) under Integrations in the Dashboard.
2. Enable the `pg_cron` extension.

</TabPanel>
<TabPanel id="sql" label="SQL">

```sql
create extension pg_cron with schema pg_catalog;

grant usage on schema cron to postgres;
grant all privileges on all tables in schema cron to postgres;
```

</TabPanel>
</Tabs>

## Uninstall

Uninstall Supabase Cron by disabling the `pg_cron` extension:

```sql
drop extension if exists pg_cron;
```

<Admonition type="warning">

Disabling the `pg_cron` extension will permanently delete all Jobs.

</Admonition>
Loading
Loading