mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 06:39:09 +03:00
Merge branch 'master' of github.com:supabase/supabase
This commit is contained in:
commit
4946817c8a
292 files changed
+20720
-30572
No files matched your search
@@ -0,0 +1,64 @@
|
||||
name: '[Docs] Lint v2 (scheduled)'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
lint-all:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
supa-mdx-lint.config.toml
|
||||
supa-mdx-lint
|
||||
apps/docs/content
|
||||
- name: cache cargo
|
||||
id: cache-cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/bin/
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
key: 1b63d22ef9b987f802cba06f01ec0da4b8eb4847
|
||||
- name: install linter
|
||||
if: steps.cache-cargo.outputs.cache-hit != 'true'
|
||||
run: cargo install --locked --git https://github.com/supabase-community/supa-mdx-lint --rev 1b63d22ef9b987f802cba06f01ec0da4b8eb4847
|
||||
- name: run linter
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
supa-mdx-lint apps/docs/content || {
|
||||
echo "Linter failed, attempting to fix errors..."
|
||||
git config --global user.name 'github-docs-bot'
|
||||
git config --global user.email 'github-docs-bot@supabase.com'
|
||||
BRANCH_NAME="bot/docs-lint-fixes"
|
||||
EXISTING_BRANCH=$(git ls-remote --heads origin $BRANCH_NAME)
|
||||
if [ -n "$EXISTING_BRANCH" ]; then
|
||||
git checkout $BRANCH_NAME
|
||||
else
|
||||
git checkout -b $BRANCH_NAME
|
||||
fi
|
||||
supa-mdx-lint apps/docs/content --fix || FIX_FAILED=1
|
||||
git add .
|
||||
git commit -m '[bot] fix lint errors' || true
|
||||
git push origin $BRANCH_NAME
|
||||
if [ -z "$EXISTING_BRANCH" ]; then
|
||||
gh pr create --title '[bot] fix lint errors' --body 'This PR fixes lint errors in the documentation.' --head $BRANCH_NAME
|
||||
fi
|
||||
if [ "${FIX_FAILED:-0}" -eq 1 ]; then
|
||||
echo "Fix did not correct all errors."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -1,20 +1,11 @@
|
||||
name: '[Docs] Lint v2'
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/docs-lint-v2.yml'
|
||||
- 'supa-mdx-lint.config.toml'
|
||||
- 'apps/docs/content/**'
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_NET_GIT_FETCH_WITH_CLI: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
@@ -29,8 +20,17 @@ jobs:
|
||||
supa-mdx-lint.config.toml
|
||||
supa-mdx-lint
|
||||
apps/docs/content
|
||||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 #v3.0.2
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
docs:
|
||||
- 'apps/docs/content/**'
|
||||
- 'supa-mdx-lint/**'
|
||||
- 'supa-mdx-lint.config.toml'
|
||||
- name: cache cargo
|
||||
id: cache-cargo
|
||||
if: steps.filter.outputs.docs == 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
@@ -38,16 +38,17 @@ jobs:
|
||||
~/.cargo/registry/index/
|
||||
~/.cargo/registry/cache/
|
||||
~/.cargo/git/db/
|
||||
key: 0be447eba738c3fd56698eff8ad01fa56c2391d7
|
||||
key: 1b63d22ef9b987f802cba06f01ec0da4b8eb4847
|
||||
- name: install linter
|
||||
if: steps.cache-cargo.outputs.cache-hit != 'true'
|
||||
run: cargo install --locked --git https://github.com/supabase-community/supa-mdx-lint --rev 0be447eba738c3fd56698eff8ad01fa56c2391d7
|
||||
if: steps.filter.outputs.docs == 'true' && steps.cache-cargo.outputs.cache-hit != 'true'
|
||||
run: cargo install --locked --git https://github.com/supabase-community/supa-mdx-lint --rev 1b63d22ef9b987f802cba06f01ec0da4b8eb4847
|
||||
- name: install reviewdog
|
||||
if: steps.filter.outputs.docs == 'true'
|
||||
uses: reviewdog/action-setup@3f401fe1d58fe77e10d665ab713057375e39b887 # v1.3.0
|
||||
with:
|
||||
reviewdog_version: v0.20.2
|
||||
- name: run linter on PR
|
||||
if: github.event_name == 'pull_request'
|
||||
- name: run linter
|
||||
if: steps.filter.outputs.docs == 'true'
|
||||
env:
|
||||
BASE_REF: ${{ github.base_ref }}
|
||||
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -57,31 +58,3 @@ jobs:
|
||||
| { grep -E "^apps/docs/content/" || test $? = 1; } \
|
||||
| xargs -r supa-mdx-lint --format rdf \
|
||||
| reviewdog -f=rdjsonl -reporter=github-pr-review
|
||||
- name: run linter on push or workflow dispatch
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
supa-mdx-lint apps/docs/content || {
|
||||
echo "Linter failed, attempting to fix errors..."
|
||||
git config --global user.name 'github-docs-bot'
|
||||
git config --global user.email 'github-docs-bot@supabase.com'
|
||||
BRANCH_NAME="bot/docs-lint-fixes"
|
||||
EXISTING_BRANCH=$(git ls-remote --heads origin $BRANCH_NAME)
|
||||
if [ -n "$EXISTING_BRANCH" ]; then
|
||||
git checkout $BRANCH_NAME
|
||||
else
|
||||
git checkout -b $BRANCH_NAME
|
||||
fi
|
||||
supa-mdx-lint apps/docs/content --fix || FIX_FAILED=1
|
||||
git add .
|
||||
git commit -m '[bot] fix lint errors' || true
|
||||
git push origin $BRANCH_NAME
|
||||
if [ -z "$EXISTING_BRANCH" ]; then
|
||||
gh pr create --title '[bot] fix lint errors' --body 'This PR fixes lint errors in the documentation.' --head $BRANCH_NAME
|
||||
fi
|
||||
if [ "${FIX_FAILED:-0}" -eq 1 ]; then
|
||||
echo "Fix did not correct all errors."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
name: reviewdog
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.vale.ini'
|
||||
- 'vale/**'
|
||||
- 'apps/docs/content/**'
|
||||
|
||||
jobs:
|
||||
vale:
|
||||
name: runner / vale
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
.vale.ini
|
||||
vale
|
||||
apps/docs/content
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
env:
|
||||
BASE_REF: ${{ github.base_ref }}
|
||||
SHA: ${{ github.sha }}
|
||||
run: |
|
||||
git fetch origin $BASE_REF
|
||||
echo "CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/$BASE_REF $SHA | grep '^apps/docs/content/' | tr '\n' ',' | sed 's/,$//')" >> $GITHUB_OUTPUT
|
||||
- uses: errata-ai/vale-action@reviewdog
|
||||
with:
|
||||
files: '${{ steps.changed-files.outputs.CHANGED_FILES }}'
|
||||
separator: ','
|
||||
@@ -53,8 +53,8 @@ You can also [self-host](https://supabase.com/docs/guides/hosting/overview) and
|
||||
- [Postgres](https://www.postgresql.org/) is an object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.
|
||||
- [Realtime](https://github.com/supabase/realtime) is an Elixir server that allows you to listen to PostgreSQL inserts, updates, and deletes using websockets. Realtime polls Postgres' built-in replication functionality for database changes, converts changes to JSON, then broadcasts the JSON over websockets to authorized clients.
|
||||
- [PostgREST](http://postgrest.org/) is a web server that turns your PostgreSQL database directly into a RESTful API.
|
||||
- [GoTrue](https://github.com/supabase/gotrue) is a JWT based API for managing users and issuing JWT tokens.
|
||||
- [Storage](https://github.com/supabase/storage-api) provides a RESTful interface for managing Files stored in S3, using Postgres to manage permissions.
|
||||
- [GoTrue](https://github.com/supabase/gotrue)is a JWT-based authentication API that simplifies user sign-ups, logins, and session management in your applications.
|
||||
- [Storage](https://github.com/supabase/storage-api)a RESTful API for managing files in S3, with Postgres handling permissions.
|
||||
- [pg_graphql](http://github.com/supabase/pg_graphql/) a PostgreSQL extension that exposes a GraphQL API.
|
||||
- [postgres-meta](https://github.com/supabase/postgres-meta) is a RESTful API for managing your Postgres, allowing you to fetch tables, add roles, and run queries, etc.
|
||||
- [Kong](https://github.com/Kong/kong) is a cloud-native API gateway.
|
||||
|
||||
@@ -388,6 +388,14 @@ void main() async {
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
|
||||
### Info Tooltip
|
||||
|
||||
The <InfoTooltip tooltipContent="This is an info tooltip">InfoTooltip</InfoTooltip> component is used to add more context to a word or phrase via tooltip.
|
||||
|
||||
```mdx
|
||||
<InfoTooltip tooltipContent="The open source Firebase alternative.">Supabase</InfoTooltip>
|
||||
```
|
||||
|
||||
## Partials
|
||||
|
||||
We incorporate content reuse in the docs to avoid duplication. If you find yourself writing the same content over and over, you can put it in a partial instead. Here are some examples of commonly used partials:
|
||||
|
||||
@@ -85,6 +85,13 @@ const pageMap = [
|
||||
},
|
||||
remoteFile: 'mssql.md',
|
||||
},
|
||||
{
|
||||
slug: 'notion',
|
||||
meta: {
|
||||
title: 'Notion',
|
||||
},
|
||||
remoteFile: 'notion.md',
|
||||
},
|
||||
{
|
||||
slug: 'paddle',
|
||||
meta: {
|
||||
|
||||
@@ -19,7 +19,6 @@ export default async function ReferencePage({
|
||||
}: {
|
||||
params: { slug: Array<string> }
|
||||
}) {
|
||||
console.log("Generating reference page for '%o'", slug)
|
||||
if (!Object.keys(REFERENCES).includes(slug[0].replaceAll('-', '_'))) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
@@ -1107,6 +1107,10 @@ export const database: NavMenuConstant = {
|
||||
name: 'Connecting to MSSQL',
|
||||
url: '/guides/database/extensions/wrappers/mssql',
|
||||
},
|
||||
{
|
||||
name: 'Connecting to Notion',
|
||||
url: '/guides/database/extensions/wrappers/notion',
|
||||
},
|
||||
{
|
||||
name: 'Connecting to Paddle',
|
||||
url: '/guides/database/extensions/wrappers/paddle',
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Admonition } from 'ui-patterns/admonition'
|
||||
import { GlassPanel } from 'ui-patterns/GlassPanel'
|
||||
import { IconPanel } from 'ui-patterns/IconPanel'
|
||||
import { TabPanel, Tabs } from '~/features/ui/Tabs'
|
||||
import InfoTooltip from '~/features/ui/InfoTooltip'
|
||||
|
||||
// Common components
|
||||
import { CH } from '@code-hike/mdx/components'
|
||||
@@ -154,6 +155,7 @@ const components = {
|
||||
OAuthPkceFlow,
|
||||
Options,
|
||||
Param,
|
||||
InfoTooltip,
|
||||
ProjectConfigVariables,
|
||||
ProjectSetup,
|
||||
QuickstartIntro,
|
||||
|
||||
@@ -462,9 +462,9 @@ Deno.serve(async (req) => {
|
||||
|
||||
// Custom headers to report job status
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Completed-Jobs': completedJobs.length.toString(),
|
||||
'X-Failed-Jobs': failedJobs.length.toString(),
|
||||
'content-type': 'application/json',
|
||||
'x-completed-jobs': completedJobs.length.toString(),
|
||||
'x-failed-jobs': failedJobs.length.toString(),
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -582,7 +582,7 @@ create table documents (
|
||||
id integer primary key generated always as identity,
|
||||
title text not null,
|
||||
content text not null,
|
||||
embedding halfvec,
|
||||
embedding halfvec(1536),
|
||||
created_at timestamp with time zone default now()
|
||||
);
|
||||
|
||||
@@ -590,7 +590,9 @@ create table documents (
|
||||
create index on documents using hnsw (embedding halfvec_cosine_ops);
|
||||
```
|
||||
|
||||
Our `documents` table stores the title and content of each document along with its vector embedding. We use a `halfvec` column to store the embeddings, which is a `pgvector` data type that stores float values in half precision (16 bits) to save space.
|
||||
Our `documents` table stores the title and content of each document along with its vector embedding. We use a `halfvec(1536)` column to store the embeddings.
|
||||
|
||||
`halfvec` is a `pgvector` data type that stores float values in half precision (16 bits) to save space. Our Edge Function used OpenAI's `text-embedding-3-small` model which generates 1536-dimensional embeddings, so we use the same dimensionality here. Adjust this based on the number of dimensions your embedding model generates.
|
||||
|
||||
We use an [HNSW index](/docs/guides/ai/vector-indexes/hnsw-indexes) on the vector column. Note that we are choosing `halfvec_cosine_ops` as the index method, which means our future queries will need to use cosine distance (`<=>`) to find similar embeddings. Also note that HNSW indexes support a maximum of 4000 dimensions for `halfvec` vectors, so keep this in mind when choosing an embedding model. If your model generates embeddings with more than 4000 dimensions, you will need to reduce the dimensionality before indexing them. See [Matryoshka embeddings](/blog/matryoshka-embeddings) for a potential solution to shortening dimensions.
|
||||
|
||||
@@ -777,11 +779,11 @@ The `embed` Edge Function processes a batch of embedding jobs and returns a `200
|
||||
It also returns the number of completed and failed jobs in the response headers. For example:
|
||||
|
||||
```
|
||||
X-Completed-Jobs: 1
|
||||
X-Failed-Jobs: 1
|
||||
x-completed-jobs: 1
|
||||
x-failed-jobs: 1
|
||||
```
|
||||
|
||||
You can also use the `X-Deno-Execution-Id` header to trace the execution of the Edge Function within the [dashboard](/dashboard/project/_/functions) logs.
|
||||
You can also use the `x-deno-execution-id` header to trace the execution of the Edge Function within the [dashboard](/dashboard/project/_/functions) logs.
|
||||
|
||||
Each failed job includes an `error` field with a description of the failure. Reasons for a job failing could include:
|
||||
|
||||
@@ -798,7 +800,7 @@ select
|
||||
from
|
||||
net._http_response
|
||||
where
|
||||
(headers->>'X-Failed-Jobs')::int > 0;
|
||||
(headers->>'x-failed-jobs')::int > 0;
|
||||
```
|
||||
|
||||
## Conclusion
|
||||
|
||||
@@ -20,6 +20,7 @@ Let's explore an example of text embeddings. Say we have three phrases:
|
||||
|
||||
1. "The cat chases the mouse"
|
||||
2. "The kitten hunts rodents"
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
3. "I like ham sandwiches"
|
||||
|
||||
Your job is to group phrases with similar meaning. If you are a human, this should be obvious. Phrases 1 and 2 are almost identical, while phrase 3 has a completely different meaning.
|
||||
|
||||
@@ -115,7 +115,7 @@ For this example, we'll upload Postgres documentation to the datastore. Download
|
||||
curl -X POST -F \\"file=@./postgresql-15-US.pdf\\" <http://localhost:3333/upsert-file>
|
||||
```
|
||||
|
||||
The plugin will split your data and documents into smaller chunks automatically. You can view the chunks using the Supabase dashboard or any other SQL client you prefer. For the whole Postgres Documentation I got 7,904 records in my documents table, which is not a lot, but we can try to add index for `embedding` column to speed things up by a little. To do so, you should run the following SQL command:
|
||||
The plugin will split your data and documents into smaller chunks automatically. You can view the chunks using the Supabase dashboard or any other SQL client you prefer. The entire Postgres Documentation yielded 7,904 records, which is not a lot, but we can try to add index for `embedding` column to speed things up by a little. To do so, you should run the following SQL command:
|
||||
|
||||
```sql
|
||||
create index on documents
|
||||
|
||||
@@ -134,7 +134,7 @@ After activating the virtual environment with `poetry shell` you can now run you
|
||||
|
||||
## Perform an image search from a text query
|
||||
|
||||
With Supabase Vector we can easily query our embeddings. We can use either an image as search input or alternative we can generate an embedding from a string input and use that as the query input:
|
||||
With Supabase Vector we can query our embeddings. We can use either an image as search input or alternative we can generate an embedding from a string input and use that as the query input:
|
||||
|
||||
```python
|
||||
def search():
|
||||
@@ -164,7 +164,7 @@ def search():
|
||||
|
||||
By limiting the query to one result, we can show the most relevant image to the user. Finally we use `matplotlib` to show the image result to the user.
|
||||
|
||||
That's it, go ahead and test it out by running `poetry run search` and you will be presented with an image of a "bike in front of a red brick wall".
|
||||
Go ahead and test it out by running `poetry run search` and you will be presented with an image of a "bike in front of a red brick wall".
|
||||
|
||||
## Conclusion
|
||||
|
||||
|
||||
@@ -391,7 +391,7 @@ All of this is glued together in a [Vercel Edge Function](https://vercel.com/doc
|
||||
|
||||
With the relevant content for the user's question identified, we can now build the prompt and make a text completion request via the OpenAI API.
|
||||
|
||||
If successful, the OpenAI API will respond with a `text/event-stream` response that we can simply forward to the client where we'll process the event stream to smoothly print the answer to the user.
|
||||
If successful, the OpenAI API will respond with a `text/event-stream` response that we can forward to the client where we'll process the event stream to smoothly print the answer to the user.
|
||||
|
||||
</StepHikeCompact.Details>
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ After activating the virtual environment with `poetry shell` you can now run you
|
||||
|
||||
## Perform an image search from a text query
|
||||
|
||||
With Supabase Vector we can easily query our embeddings. We can use either an image as the search input or alternatively we can generate an embedding from a string input and use that as the query input:
|
||||
We can use Supabase Vector to query our embeddings. We can either use an image as the search input or generate an embedding from a string input:
|
||||
|
||||
```python
|
||||
def search(query_term: Optional[str] = None):
|
||||
@@ -227,7 +227,7 @@ def search(query_term: Optional[str] = None):
|
||||
|
||||
By limiting the query to one result, we can show the most relevant image to the user. Finally we use `matplotlib` to show the image result to the user.
|
||||
|
||||
That's it, go ahead and test it out by running `poetry run search` and you will be presented with an image of a "bike in front of a red brick wall".
|
||||
Go ahead and test it out by running `poetry run search` and you will be presented with an image of a "bike in front of a red brick wall".
|
||||
|
||||
## Conclusion
|
||||
|
||||
|
||||
@@ -50,8 +50,8 @@ https://huggingface.co/settings/tokens
|
||||
|
||||
Name your token based on the app its being used for and the environment. For example, if you are building an image generation app you might create 2 tokens:
|
||||
|
||||
- "My Image Generator (Dev)"
|
||||
- "My Image Generator (Prod)"
|
||||
- "Image Generator (Dev)"
|
||||
- "Image Generator (Prod)"
|
||||
|
||||
Since we will be using this token for the inference API, choose the `read` role.
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ sidebar_label: 'Hybrid search'
|
||||
|
||||
Hybrid search combines [full text search](/docs/guides/ai/keyword-search) (searching by keyword) with [semantic search](/docs/guides/ai/semantic-search) (searching by meaning) to identify results that are both directly and contextually relevant to the user's query.
|
||||
|
||||
## Why would I want to use hybrid search?
|
||||
## Use cases for hybrid search
|
||||
|
||||
Sometimes a single search method doesn't quite capture what a user is really looking for. For example, if a user searches for "Italian recipes with tomato sauce" on a cooking app, a keyword search would pull up recipes that specifically mention "Italian," "recipes," and "tomato sauce" in the text. However, it might miss out on dishes that are quintessentially Italian and use tomato sauce but don't explicitly label themselves with these words, or use variations like "pasta sauce" or "marinara." On the other hand, a semantic search might understand the culinary context and find recipes that match the intent, such as a traditional "Spaghetti Marinara," even if they don't match the exact keyword phrase. However, it could also suggest recipes that are contextually related but not what the user is looking for, like a "Mexican salsa" recipe, because it understands the context to be broadly about tomato-based sauces.
|
||||
|
||||
Hybrid search combines the strengths of both these methods. It would ensure that recipes explicitly mentioning the keywords are prioritized, thus capturing direct hits that satisfy the keyword criteria. At the same time, it would include recipes identified through semantic understanding as being related in meaning or context, like different Italian dishes that traditionally use tomato sauce but might not have been tagged explicitly with the user's search terms. It identifies results that are both directly and contextually relevant to the user's query while ideally minimizing misses and irrelevant suggestions.
|
||||
|
||||
## When would I want to use hybrid search?
|
||||
## When to consider hybrid search
|
||||
|
||||
The decision to use hybrid search depends on what your users are looking for in your app. For a code repository where developers need to find exact lines of code or error messages, keyword search is likely ideal because it matches specific terms. In a mental health forum where users search for advice or experiences related to their feelings, semantic search may be better because it finds results based on the meaning of a query, not just specific words. For a shopping app where customers might search for specific product names yet also be open to related suggestions, hybrid search combines the best of both worlds - finding exact matches while also uncovering similar products based on the shopping context.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ tocVideo: 'A3uND5sgiO0'
|
||||
|
||||
[Amazon Bedrock](https://aws.amazon.com/bedrock) is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon. Each model is accessible through a common API which implements a broad set of features to help build generative AI applications with security, privacy, and responsible AI in mind.
|
||||
|
||||
This guide will walk you through an example using Amazon Bedrock SDK with `vecs`. We will create embeddings using the Amazon Titan Embeddings G1 – Text v1.2 (amazon.titan-embed-text-v1) model, insert these embeddings into a PostgreSQL database using vecs, and then query the collection to find the most similar sentences to a given query sentence.
|
||||
This guide will walk you through an example using Amazon Bedrock SDK with `vecs`. We will create embeddings using the Amazon Titan Embeddings G1 – Text v1.2 (amazon.titan-embed-text-v1) model, insert these embeddings into a Postgres database using vecs, and then query the collection to find the most similar sentences to a given query sentence.
|
||||
|
||||
## Create an environment
|
||||
|
||||
@@ -69,7 +69,7 @@ for sentence in dataset:
|
||||
|
||||
### Store the embeddings with vecs
|
||||
|
||||
Now that we have our embeddings, we can insert them into a PostgreSQL database using vecs.
|
||||
Now that we have our embeddings, we can insert them into a Postgres database using vecs.
|
||||
|
||||
```python
|
||||
import vecs
|
||||
|
||||
@@ -10,7 +10,7 @@ Keyword search involves locating documents or records that contain specific word
|
||||
|
||||
In Postgres, keyword search is implemented using [full-text search](/docs/guides/database/full-text-search). It supports indexing and text analysis for data retrieval, focusing on records that match the search criteria. Postgres' full-text search extends beyond simple keyword matching to address linguistic nuances, making it effective for applications that require precise text queries.
|
||||
|
||||
## Why would I want to use keyword search?
|
||||
## When and why to use keyword search
|
||||
|
||||
Keyword search is particularly useful in scenarios where precision and specificity matter. It's more effective than semantic search when users are looking for information using exact terminology or specific identifiers. It ensures that results directly contain those terms, reducing the chance of retrieving irrelevant information that might be semantically related but not what the user seeks.
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ RLS is latency-sensitive, so extra caution should be taken before implementing t
|
||||
|
||||
<Admonition type="tip">
|
||||
|
||||
For data sources other than Postgres, see [Foreign Data Wrappers](/docs/guides/database/extensions/wrappers/overview) for a list of external sources supported today. If your data lives in a source not provided in the list, please contact [support](https://supabase.com/dashboard/support/new) and we'll be happy to discuss your use case.
|
||||
For data sources other than Postgres, see [Foreign Data Wrappers](/docs/guides/database/extensions/wrappers/overview) for a list of external sources supported today. If your data lives in a source not provided in the list, contact [support](https://supabase.com/dashboard/support/new) and we'll be happy to discuss your use case.
|
||||
|
||||
</Admonition>
|
||||
|
||||
@@ -226,6 +226,8 @@ order by document_sections.embedding <#> embedding;
|
||||
|
||||
<Admonition type="caution">
|
||||
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
|
||||
You might be tempted to discard RLS completely and simply filter by user within the `where` clause. Though this will work, we recommend RLS as a general best practice since RLS is always applied even as new queries and application logic is introduced in the future.
|
||||
|
||||
</Admonition>
|
||||
@@ -236,7 +238,7 @@ If you would like to use the auto-generated REST API to query your Supabase data
|
||||
|
||||
See the [Clerk Supabase docs](https://clerk.com/docs/integrations/databases/supabase) for an example of how this can be done. Modify the instructions to work with your own auth provider as needed.
|
||||
|
||||
Now we can simply use the same RLS policy from our first example:
|
||||
Now we can use the same RLS policy from our first example:
|
||||
|
||||
```sql
|
||||
-- enable row level security
|
||||
|
||||
@@ -5,7 +5,7 @@ subtitle: 'Manage unstructured vector stores in PostgreSQL.'
|
||||
breadcrumb: 'AI Quickstarts'
|
||||
---
|
||||
|
||||
Supabase provides a Python client called [`vecs`](https://github.com/supabase/vecs) for managing unstructured vector stores. This client provides a set of useful tools for creating and querying collections in PostgreSQL using the [pgvector](/docs/guides/database/extensions/pgvector) extension.
|
||||
Supabase provides a Python client called [`vecs`](https://github.com/supabase/vecs) for managing unstructured vector stores. This client provides a set of useful tools for creating and querying collections in Postgres using the [pgvector](/docs/guides/database/extensions/pgvector) extension.
|
||||
|
||||
## Quick start
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ sidebar_label: 'Vector columns'
|
||||
|
||||
Supabase offers a number of different ways to store and query vectors within Postgres. The SQL included in this guide is applicable for clients in all programming languages. If you are a Python user see your [Python client options](/docs/guides/ai/python-clients) after reading the `Learn` section.
|
||||
|
||||
Vectors in Supabase are enabled via [pgvector](https://github.com/pgvector/pgvector/), a PostgreSQL extension for storing and querying vectors in Postgres. It can be used to store [embeddings](/docs/guides/ai/concepts#what-are-embeddings).
|
||||
Vectors in Supabase are enabled via [pgvector](https://github.com/pgvector/pgvector/), a Postgres extension for storing and querying vectors in Postgres. It can be used to store [embeddings](/docs/guides/ai/concepts#what-are-embeddings).
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ title: A DESCRIPTIVE TITLE
|
||||
subtitle: A DESCRIPTIVE SUBTITLE
|
||||
---
|
||||
|
||||
{/* supa-mdx-lint-disable */}
|
||||
|
||||
{/* Use this template to document Auth Flows. These should be how-to guides, walking the reader through the process of (1) enabling the feature and (2) triggering the flow from their code. */}
|
||||
|
||||
A brief description of what this flow does. Don't get into details: if the concepts require a lot of explanation, make a separate page under Concepts.
|
||||
|
||||
@@ -125,6 +125,8 @@ response = supabase.auth.sign_in_with_otp({
|
||||
</TabPanel>
|
||||
</Tabs>
|
||||
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
|
||||
That's it for the implicit flow.
|
||||
|
||||
If you're using PKCE flow, edit the Magic Link [email template](/docs/guides/auth/auth-email-templates) to send a token hash:
|
||||
|
||||
@@ -685,7 +685,7 @@ To make these helpers more flexible as well as more maintainable and easier to u
|
||||
|
||||
Therefore we're marking the `withApiAuth`, `withPageAuth`, and `withMiddlewareAuth` higher order functions as deprecated and they will be removed in the next **minor** release (v0.6.X).
|
||||
|
||||
Please follow the steps below to update your API routes, pages, and middleware handlers. Thanks!
|
||||
Follow the steps below to update your API routes, pages, and middleware handlers. Thanks!
|
||||
|
||||
#### `withApiAuth` deprecated!
|
||||
|
||||
@@ -874,9 +874,9 @@ export const config = {
|
||||
|
||||
### Migrating to v0.4.X and supabase-js v2
|
||||
|
||||
With the update to `supabase-js` v2 the `auth` API routes are no longer required, therefore you can go ahead and delete your `auth` directory under the `/pages/api/` directory. Please refer to the [v2 migration guide](/docs/reference/javascript/v1/upgrade-guide) for the full set of changes within supabase-js.
|
||||
With the update to `supabase-js` v2 the `auth` API routes are no longer required, therefore you can go ahead and delete your `auth` directory under the `/pages/api/` directory. Refer to the [v2 migration guide](/docs/reference/javascript/v1/upgrade-guide) for the full set of changes within supabase-js.
|
||||
|
||||
The `/api/auth/logout` API route has been removed, please use the `signout` method instead:
|
||||
The `/api/auth/logout` API route has been removed, use the `signout` method instead:
|
||||
|
||||
```jsx
|
||||
<button
|
||||
|
||||
@@ -683,7 +683,7 @@ There are 5 ways to access the Supabase client with the Next.js Auth Helpers:
|
||||
- [Route Handlers](/docs/guides/auth/auth-helpers/nextjs#route-handlers) — `createRouteHandlerClient` in Route Handlers
|
||||
- [Middleware](/docs/guides/auth/auth-helpers/nextjs#middleware) — `createMiddlewareClient` in Middleware
|
||||
|
||||
This allows for the Supabase client to be easily instantiated in the correct context. All you need to change is the context in the middle `create[ClientComponent|ServerComponent|ServerAction|RouteHandler|Middleware]Client` and the Auth Helpers will take care of the rest.
|
||||
This allows for the Supabase client to be instantiated in the correct context. All you need to change is the context in the middle `create[ClientComponent|ServerComponent|ServerAction|RouteHandler|Middleware]Client` and the Auth Helpers will take care of the rest.
|
||||
|
||||
### Client components
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ uri = "http://host.docker.internal:54321/functions/v1/send_sms"
|
||||
secrets = "env(SEND_SMS_HOOK_SECRETS)"
|
||||
```
|
||||
|
||||
<Admonition type="info">
|
||||
<Admonition type="note">
|
||||
|
||||
`host.docker.internal` is a special DNS name used in Docker to allow a container to access the host machine's network. This allows the Auth container to reach your HTTP function, no matter if it's a Supabase Edge Function or a custom endpoint.
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ Deno.serve(async (req) => {
|
||||
)
|
||||
}
|
||||
return new Response(
|
||||
{},
|
||||
JSON.stringify({}),
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
|
||||
@@ -175,7 +175,7 @@ Your app should sufficiently deny or allow access to tables or rows based on the
|
||||
|
||||
<Admonition type="caution">
|
||||
|
||||
PostgreSQL has two types of policies: permissive and restrictive. This guide uses restrictive policies. Make sure you don't omit the `as restrictive` clause.
|
||||
Postgres has two types of policies: permissive and restrictive. This guide uses restrictive policies. Make sure you don't omit the `as restrictive` clause.
|
||||
|
||||
</Admonition>
|
||||
|
||||
@@ -328,7 +328,7 @@ For example, the following structure describes a user that first signed in with
|
||||
|
||||
Use the `supabase.auth.mfa.getAuthenticatorAssuranceLevel()` method to get easy access to this information in your browser app.
|
||||
|
||||
You can use this PostgreSQL snippet in RLS policies, too:
|
||||
You can use this Postgres snippet in RLS policies, too:
|
||||
|
||||
```sql
|
||||
jsonb_path_query((select auth.jwt()), '$.amr[0]')
|
||||
|
||||
@@ -308,7 +308,7 @@ function AuthMFA() {
|
||||
|
||||
Each code is valid for up to 5 minutes, after which a new one can be sent. Successive codes remain valid until expiry. When possible choose the longest code length acceptable to your use case, at a minimum of 6. This can be configured in the [Authentication Settings](/dashboard/project/_/settings/auth).
|
||||
|
||||
Please be aware that Phone MFA is vulnerable to SIM swap attacks where an attacker will call a mobile provider and ask to port the target's phone number to a new SIM card and then use the said SIM card to intercept an MFA code. Please evaluate the your application's tolerance for such an attack. You can read more about SIM swapping attacks [here](https://en.wikipedia.org/wiki/SIM_swap_scam)
|
||||
Be aware that Phone MFA is vulnerable to SIM swap attacks where an attacker will call a mobile provider and ask to port the target's phone number to a new SIM card and then use the said SIM card to intercept an MFA code. Evaluate the your application's tolerance for such an attack. You can read more about SIM swapping attacks [here](https://en.wikipedia.org/wiki/SIM_swap_scam)
|
||||
|
||||
## Pricing
|
||||
|
||||
|
||||
@@ -19,17 +19,16 @@ Supabase Auth supports enterprise-level Single Sign-On (SSO) for any identity pr
|
||||
- PingIdentity
|
||||
- OneLogin
|
||||
|
||||
If you're having issues with identity provider software not on this list, please [open a support ticket](https://supabase.com/dashboard/support/new).
|
||||
If you're having issues with identity provider software not on this list, [open a support ticket](https://supabase.com/dashboard/support/new).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This guide requires the use of the [Supabase CLI](/docs/guides/cli). Please make sure you're using version v1.46.4 or higher. You can use `supabase -v` to see the currently installed version.
|
||||
|
||||
This guide requires the use of the [Supabase CLI](/docs/guides/cli). Make sure you're using version v1.46.4 or higher. You can use `supabase -v` to see the currently installed version.
|
||||
You can use the `supabase sso` [subcommands](/docs/reference/cli/supabase-sso) to manage your project's configuration.
|
||||
|
||||
SAML 2.0 support is disabled by default on Supabase projects. You can configure this on the [Auth Providers](https://supabase.com/dashboard/project/_/auth/providers) page on your project.
|
||||
|
||||
Please note that SAML 2.0 support is offered on plans Pro and above. Check the [Pricing](https://supabase.com/pricing) page for more information.
|
||||
Note that SAML 2.0 support is offered on plans Pro and above. Check the [Pricing](https://supabase.com/pricing) page for more information.
|
||||
|
||||
## Terminology
|
||||
|
||||
@@ -82,7 +81,7 @@ User accounts and identities created via SSO differ from regular (email, phone,
|
||||
- **No automatic linking.**
|
||||
Each user account verified using a SSO identity provider will not be automatically linked to existing user accounts in the system. That is, if a user `valid.email@supabase.io` had signed up with a password, and then uses their company SSO login with your project, there will be two `valid.email@supabase.io` user accounts in the system.
|
||||
- **Emails are not necessarily unique.**
|
||||
Given the behavior with no automatic linking, email addresses are no longer a unique identifier for a user account. Please always use the user's UUID to correctly reference user accounts.
|
||||
Given the behavior with no automatic linking, email addresses are no longer a unique identifier for a user account. Always use the user's UUID to correctly reference user accounts.
|
||||
- **Sessions may have a maximum duration.**
|
||||
Depending on the configuration of the identity provider, a login session established with SSO may forcibly log out a user after a certain period of time.
|
||||
|
||||
@@ -176,7 +175,7 @@ supabase sso add --type saml --project-ref <your-project> \
|
||||
|
||||
This command will register a new identity provider with your project's Auth server. When successful, you will see the details of the provider such as it's SAML information and registered domains.
|
||||
|
||||
Please note that only persons with write access to the project can register, update or remove identity providers.
|
||||
Note that only persons with write access to the project can register, update or remove identity providers.
|
||||
|
||||
Once you've added an identity provider, users who have access to it can sign in to your application. With SAML 2.0 there are two ways that users can sign in to your project:
|
||||
|
||||
@@ -319,7 +318,7 @@ Supabase Auth does not require specifying attribute mappings if you only need ac
|
||||
|
||||
At this time it is not possible to have users without an email address, so SAML assertions without one will be rejected.
|
||||
|
||||
Most SAML 2.0 identity providers use Lightweight Directory Access Protocol (LDAP) attribute names. However, due to their variability and complexity operators of identity providers are able to customize both the `Name` and attribute value that is sent to Supabase Auth in an assertion. Please refer to the identity provider's documentation and contact the operator for details on what attributes are mapped for your project.
|
||||
Most SAML 2.0 identity providers use Lightweight Directory Access Protocol (LDAP) attribute names. However, due to their variability and complexity operators of identity providers are able to customize both the `Name` and attribute value that is sent to Supabase Auth in an assertion. Refer to the identity provider's documentation and contact the operator for details on what attributes are mapped for your project.
|
||||
|
||||
**Accessing the stored attributes**
|
||||
|
||||
@@ -337,8 +336,7 @@ supabase sso remove <provider-id> --project-ref <your-project>
|
||||
|
||||
If successful, the details of the removed identity provider will be shown. All user accounts from that identity provider will be immediately logged out. User information will remain in the system, but it will no longer be possible for any of those accounts to be accessed in the future, even if you add the connection again.
|
||||
|
||||
If you need to reassign those user accounts to another identity provider, please [open a support ticket](https://supabase.com/dashboard/support/new).
|
||||
|
||||
If you need to reassign those user accounts to another identity provider, [open a support ticket](https://supabase.com/dashboard/support/new).
|
||||
A [list of all](/docs/reference/cli/supabase-sso-list) registered identity providers can be displayed by running:
|
||||
|
||||
```bash
|
||||
@@ -362,7 +360,7 @@ You can use this command to [update](/docs/reference/cli/supabase-sso-update) th
|
||||
supabase sso update <provider-id> --project-ref <your-project>
|
||||
```
|
||||
|
||||
Please use `--help` to see all available flags.
|
||||
Use `--help` to see all available flags.
|
||||
|
||||
It is not possible to change the unique SAML identifier of the identity provider, known as `EntityID`. Everything else can be updated. If the SAML `EntityID` of your identity provider has changed, it is regarded as a new identity provider and you will have to register it like a new connection.
|
||||
|
||||
@@ -380,7 +378,7 @@ This list will only include basic information about each provider. To see [all o
|
||||
supabase sso show <provider-id> --project-ref <your-project>
|
||||
```
|
||||
|
||||
You can use the `-o json` flag to output the information as JSON, should you need to. Other formats may be supported, please use `--help` to see all available options.
|
||||
You can use the `-o json` flag to output the information as JSON, should you need to. Other formats may be supported, use `--help` to see all available options.
|
||||
|
||||
## Pricing
|
||||
|
||||
@@ -390,11 +388,11 @@ For a detailed breakdown of how charges are calculated, refer to [Manage Monthly
|
||||
|
||||
## Frequently asked questions
|
||||
|
||||
### How do I publish my application to an identity provider's marketplace?
|
||||
### Publishing your application to an identity provider's marketplace
|
||||
|
||||
Many cloud-based identity providers offer a marketplace where you can register your application for easy on-boarding with customers. When you use Supabase Auth's SAML 2.0 support you can register your project in any one of these marketplaces.
|
||||
|
||||
Please refer to the relevant documentation for each cloud-based identity provider on how you can do this. Some common marketplaces are:
|
||||
Refer to the relevant documentation for each cloud-based identity provider on how you can do this. Some common marketplaces are:
|
||||
|
||||
- [Okta Integration Network](https://developer.okta.com/docs/guides/build-sso-integration/saml2/main/)
|
||||
- [Azure Active Directory App Gallery](https://learn.microsoft.com/en-us/azure/active-directory-b2c/publish-app-to-azure-ad-app-gallery)
|
||||
@@ -414,13 +412,13 @@ The following list of commonly used SAML attribute names is inspected, in order
|
||||
|
||||
Finally if there is no such attribute, it will use the SAML `NameID` value but only if the format is advertised as `urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`.
|
||||
|
||||
Should you run into this problem, it is most likely a misconfiguration issue **on the identity provider side.** Please instruct your contact at the company to map the user's email address to one of the above listed attribute names, typically `email`.
|
||||
Should you run into this problem, it is most likely a misconfiguration issue **on the identity provider side.** Instruct your contact at the company to map the user's email address to one of the above listed attribute names, typically `email`.
|
||||
|
||||
### How do I access the private key used for SAML in my project?
|
||||
### Accessing the private key used for SAML in your project
|
||||
|
||||
At this time it is not possible to extract the RSA private key used by your project's Supabase Auth server. This is done to keep the private key as secure as possible, given that SAML does not offer an easy way to rotate keys without disrupting service. (Please use a SAML 2.0 Metadata URL whenever possible for this reason!)
|
||||
At this time it is not possible to extract the RSA private key used by your project's Supabase Auth server. This is done to keep the private key as secure as possible, given that SAML does not offer an easy way to rotate keys without disrupting service. (Use a SAML 2.0 Metadata URL whenever possible for this reason!)
|
||||
|
||||
If you really need access to the key, please [open a support ticket](https://supabase.com/dashboard/support/new) and we'll try to support you as best as possible.
|
||||
If you really need access to the key, [open a support ticket](https://supabase.com/dashboard/support/new) and we'll try to support you as best as possible.
|
||||
|
||||
### Is multi-tenant SSO with SAML supported?
|
||||
|
||||
|
||||
@@ -91,9 +91,11 @@ You can test out minting your own tokens on [https://jwt.io](https://jwt.io).
|
||||
|
||||
It is important to note that anyone who possesses the `jwt_secret` here can create new tokens, and also verify existing ones. More advanced JWT algorithms use two secrets: one for the creation of tokens, and a separate one to verify the validity of signed tokens.
|
||||
|
||||
You might wonder why JWTs are so popular all of a sudden. The answer is that with the mass adoption of microservice architecture, we were in a situation where several distinct microservices (APIs, websites, servers, etc.) want to easily validate that a user is who they say they are, or are in other words a "logged-in" user. Traditional session tokens are no use here, since they would require each microservice to either maintain a record of currently valid session tokens or to query a central database each time a user wants to access a resource in order to check the validity of the session token – very inefficient indeed. JWT-based auth in this sense is decentralized, since anyone with the `jwt_secret` can verify a token without needing access to a centralized database.
|
||||
You might wonder why JWTs are so popular all of a sudden. The answer is that with the mass adoption of microservice architecture, we were in a situation where several distinct microservices (APIs, websites, servers, etc.) want to validate that a user is who they say they are, or are in other words a "logged-in" user. Traditional session tokens are no use here, since they would require each microservice to either maintain a record of currently valid session tokens or to query a central database each time a user wants to access a resource in order to check the validity of the session token – very inefficient indeed. JWT-based auth in this sense is decentralized, since anyone with the `jwt_secret` can verify a token without needing access to a centralized database.
|
||||
|
||||
Note: One downside of JWTs is that they are not easily voidable, like session tokens. If a JWT is leaked to a malicious actor, they will be able to redeem it anywhere until the expiry date is reached – unless of course the system owner updates the `jwt_secret` (which will of course invalidate _everyone's_ existing tokens).
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
|
||||
Note: One downside of JWTs is that they are not easily voidable, unlike session tokens. If a JWT is leaked to a malicious actor, they will be able to redeem it anywhere until the expiry date is reached – unless of course the system owner updates the `jwt_secret` (which will of course invalidate _everyone's_ existing tokens).
|
||||
|
||||
## JWTs in Supabase
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ alter table public.profiles enable row level security;
|
||||
|
||||
<Admonition type="caution">
|
||||
|
||||
Only use primary keys as [foreign key references](https://www.postgresql.org/docs/current/tutorial-fk.html) for schemas and tables like `auth.users` which are managed by Supabase. PostgreSQL lets you specify a foreign key reference for columns backed by a unique index (not necessarily primary keys).
|
||||
Only use primary keys as [foreign key references](https://www.postgresql.org/docs/current/tutorial-fk.html) for schemas and tables like `auth.users` which are managed by Supabase. Postgres lets you specify a foreign key reference for columns backed by a unique index (not necessarily primary keys).
|
||||
|
||||
Primary keys are **guaranteed not to change**. Columns, indices, constraints or other database objects managed by Supabase **may change at any time** and you should be careful when referencing them directly.
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ The PKCE flow allows for server-side authentication. Unlike the implicit flow, w
|
||||
|
||||
##### Step 1: Update signup confirmation email
|
||||
|
||||
Update your signup email template to send the token hash. For detailed instructions on how to configure your email templates, including the use of variables like `{{ .SiteURL }}`, `{{ .TokenHash }}`, and `{{ .RedirectTo }}`, please refer to our [Email Templates](/docs/guides/auth/auth-email-templates) guide.
|
||||
Update your signup email template to send the token hash. For detailed instructions on how to configure your email templates, including the use of variables like `{{ .SiteURL }}`, `{{ .TokenHash }}`, and `{{ .RedirectTo }}`, refer to our [Email Templates](/docs/guides/auth/auth-email-templates) guide.
|
||||
|
||||
Your signup email template should contain the following HTML:
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ For an implementation example, see the [@supabase/ssr](https://github.com/supaba
|
||||
|
||||
## Frequently asked questions
|
||||
|
||||
{/* supa-mdx-lint-disable Rule004ExcludeWords */}
|
||||
|
||||
### No session on the server side with Next.js route prefetching?
|
||||
|
||||
When you use route prefetching in Next.js using `<Link href="/...">` components or the `Router.push()` APIs can send server-side requests before the browser processes the access and refresh tokens. This means that those requests may not have any cookies set and your server code will render unauthenticated content.
|
||||
|
||||
@@ -61,7 +61,7 @@ To make sure that sessions expire after a period of inactivity, you can set a po
|
||||
|
||||
You can also enforce only one active session per user per device or browser. When this is enabled, the session from the most recent sign in will remain active, while the rest are terminated. Enable this via the _Single session per user_ option in the [Auth settings](/dashboard/project/_/settings/auth).
|
||||
|
||||
Sessions are not proactively destroyed when you change these settings, but rather the check is enforced whenever a session is refreshed next. This can confuse developers because the actual duration of a session is the configured timeout plus the JWT expiration time. For single session per user, the effect will only be noticed at intervals of the JWT expiration time. Please make sure you adjust this setting depending on your needs. We do not recommend going below 5 minutes for the JWT expiration time.
|
||||
Sessions are not proactively destroyed when you change these settings, but rather the check is enforced whenever a session is refreshed next. This can confuse developers because the actual duration of a session is the configured timeout plus the JWT expiration time. For single session per user, the effect will only be noticed at intervals of the JWT expiration time. Make sure you adjust this setting depending on your needs. We do not recommend going below 5 minutes for the JWT expiration time.
|
||||
|
||||
Otherwise sessions are progressively deleted from the database 24 hours after they expire, which prevents you from causing a high load on your project by accident and allows you some freedom to undo changes without adversely affecting all users.
|
||||
|
||||
@@ -111,7 +111,7 @@ Supabase Auth prefers a JWT-based approach using access and refresh tokens are b
|
||||
|
||||
It's better for cost optimization and scaling as well, as the authentication system's servers and database only handle traffic for this use case.
|
||||
|
||||
### How do I make sure that an access token (JWT) cannot be used after a user clicks sign out?
|
||||
### How to ensure an access token (JWT) cannot be used after a user signs out
|
||||
|
||||
Most applications rarely need such strong guarantees. Consider adjusting the JWT expiry time to an acceptable value. If this is still necessary, you should try to use this validation logic only for the most sensitive actions within your application.
|
||||
|
||||
@@ -119,7 +119,7 @@ When a user signs out, the sessions affected by the logout are removed from the
|
||||
|
||||
Note that sessions are not proactively terminated when their maximum lifetime (time-box) or inactivity timeout are reached. These sessions are cleaned up progressively 24 hours after reaching that status. This allows you to tweak the values or roll back changes without causing unintended user friction.
|
||||
|
||||
### Can I use HTTP-only cookies to store the access and refresh tokens?
|
||||
### Using HTTP-only cookies to store access and refresh tokens
|
||||
|
||||
This is possible, but only for apps that use the traditional server-only web app approach where all of the application logic is implemented on the server and it returns rendered HTML only.
|
||||
|
||||
|
||||
@@ -55,17 +55,17 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,
|
||||
|
||||
You will require the following information:
|
||||
|
||||
1. Your Apple Developer account's **Team ID**, which is an alphanumeric string of 10 characters that uniquely identifies the developer of the app. It's often easily accessible in the upper right-side menu on the Apple Developer Console.
|
||||
1. Your Apple Developer account's **Team ID**, which is an alphanumeric string of 10 characters that uniquely identifies the developer of the app. It's often accessible in the upper right-side menu on the Apple Developer Console.
|
||||
2. Register email sources for _Sign in with Apple for Email Communication_ which can be found in the [Services](https://developer.apple.com/account/resources/services/list) section of the Apple Developer Console.
|
||||
3. An **App ID** which uniquely identifies the app you are building. You can create a new App ID from the [Identifiers](https://developer.apple.com/account/resources/identifiers/list/bundleId) section in the Apple Developer Console (use the filter menu in the upper right side to see all App IDs). These usually are a reverse domain name string, for example `com.example.app`. Make sure you configure Sign in with Apple once you create an App ID in the Capabilities list. At this time Supabase Auth does not support Server-to-Server notification endpoints, so you should leave that setting blank. (In the past App IDs were referred to as _bundle IDs._)
|
||||
4. A **Services ID** which uniquely identifies the web services provided by the app you registered in the previous step. You can create a new Services ID from the [Identifiers](https://developer.apple.com/account/resources/identifiers/list/serviceId) section in the Apple Developer Console (use the filter menu in the upper right side to see all Services IDs). These usually are a reverse domain name string, for example `com.example.app.web`.
|
||||
5. Configure Website URLs for the newly created **Services ID**. The web domain you should use is the domain your Supabase project is hosted on. This is usually `<project-id>.supabase.co` while the redirect URL is `https://<project-id>.supabase.co/auth/v1/callback`.
|
||||
6. Create a signing **Key** in the [Keys](https://developer.apple.com/account/resources/authkeys/list) section of the Apple Developer Console. You can use this key to generate a secret key using the tool below, which is added to your Supabase project's Auth configuration. Make sure you safely store the `AuthKey_XXXXXXXXXX.p8` file. If you ever lose access to it, or make it public accidentally please revoke it from the Apple Developer Console and create a new one immediately. You will have to generate a new secret key using this file every 6 months, so make sure you schedule a recurring meeting in your calendar!
|
||||
6. Create a signing **Key** in the [Keys](https://developer.apple.com/account/resources/authkeys/list) section of the Apple Developer Console. You can use this key to generate a secret key using the tool below, which is added to your Supabase project's Auth configuration. Make sure you safely store the `AuthKey_XXXXXXXXXX.p8` file. If you ever lose access to it, or make it public accidentally, revoke it from the Apple Developer Console and create a new one immediately. You will have to generate a new secret key using this file every 6 months, so make sure you schedule a recurring meeting in your calendar!
|
||||
7. Finally, add the information you configured above to the [Apple provider configuration in the Supabase dashboard](https://supabase.com/dashboard/project/_/auth/providers).
|
||||
|
||||
<Admonition type="tip">
|
||||
|
||||
Use this tool to generate a new Apple client secret. No keys leave your browser! Be aware that this tool does not currently work in Safari, so please use Firefox or a Chrome-based browser instead.
|
||||
Use this tool to generate a new Apple client secret. No keys leave your browser! Be aware that this tool does not currently work in Safari, so use Firefox or a Chrome-based browser instead.
|
||||
|
||||
</Admonition>
|
||||
|
||||
@@ -102,7 +102,7 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,
|
||||
})
|
||||
```
|
||||
|
||||
Please make sure you request for the scope `name email` when initializing the library.
|
||||
Make sure you request for the scope `name email` when initializing the library.
|
||||
|
||||
### Configuration [#configuration-apple-js]
|
||||
|
||||
@@ -272,17 +272,17 @@ When developing with Expo, you can test Sign in with Apple via the Expo Go app,
|
||||
|
||||
You will require the following information:
|
||||
|
||||
1. Your Apple Developer account's **Team ID**, which is an alphanumeric string of 10 characters that uniquely identifies the developer of the app. It's often easily accessible in the upper right-side menu on the Apple Developer Console.
|
||||
1. Your Apple Developer account's **Team ID**, which is an alphanumeric string of 10 characters that uniquely identifies the developer of the app. It's often accessible in the upper right-side menu on the Apple Developer Console.
|
||||
2. Register email sources for _Sign in with Apple for Email Communication_ which can be found in the [Services](https://developer.apple.com/account/resources/services/list) section of the Apple Developer Console.
|
||||
3. An **App ID** which uniquely identifies the app you are building. You can create a new App ID from the [Identifiers](https://developer.apple.com/account/resources/identifiers/list/bundleId) section in the Apple Developer Console (use the filter menu in the upper right side to see all App IDs). These usually are a reverse domain name string, for example `com.example.app`. Make sure you configure Sign in with Apple once you create an App ID in the Capabilities list. At this time Supabase Auth does not support Server-to-Server notification endpoints, so you should leave that setting blank. (In the past App IDs were referred to as _bundle IDs._)
|
||||
4. A **Services ID** which uniquely identifies the web services provided by the app you registered in the previous step. You can create a new Services ID from the [Identifiers](https://developer.apple.com/account/resources/identifiers/list/serviceId) section in the Apple Developer Console (use the filter menu in the upper right side to see all Services IDs). These usually are a reverse domain name string, for example `com.example.app.web`.
|
||||
5. Configure Website URLs for the newly created **Services ID**. The web domain you should use is the domain your Supabase project is hosted on. This is usually `<project-id>.supabase.co` while the redirect URL is `https://<project-id>.supabase.co/auth/v1/callback`.
|
||||
6. Create a signing **Key** in the [Keys](https://developer.apple.com/account/resources/authkeys/list) section of the Apple Developer Console. You can use this key to generate a secret key using the tool below, which is added to your Supabase project's Auth configuration. Make sure you safely store the `AuthKey_XXXXXXXXXX.p8` file. If you ever lose access to it, or make it public accidentally please revoke it from the Apple Developer Console and create a new one immediately. You will have to generate a new secret key using this file every 6 months, so make sure you schedule a recurring reminder in your calendar!
|
||||
6. Create a signing **Key** in the [Keys](https://developer.apple.com/account/resources/authkeys/list) section of the Apple Developer Console. You can use this key to generate a secret key using the tool below, which is added to your Supabase project's Auth configuration. Make sure you safely store the `AuthKey_XXXXXXXXXX.p8` file. If you ever lose access to it, or make it public accidentally, revoke it from the Apple Developer Console and create a new one immediately. You will have to generate a new secret key using this file every 6 months, so make sure you schedule a recurring reminder in your calendar!
|
||||
7. Finally, add the information you configured above to the [Apple provider configuration in the Supabase dashboard](https://supabase.com/dashboard/project/_/auth/providers).
|
||||
|
||||
<Admonition type="tip">
|
||||
|
||||
Use this tool to generate a new Apple client secret. No keys leave your browser! Be aware that this tool does not currently work in Safari, so please use Firefox or a Chrome-based browser instead.
|
||||
Use this tool to generate a new Apple client secret. No keys leave your browser! Be aware that this tool does not currently work in Safari, so use Firefox or a Chrome-based browser instead.
|
||||
|
||||
</Admonition>
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ By default, Supabase Auth uses the _common_ Microsoft tenant (`https://login.mic
|
||||
|
||||
If your app is registered as _Personal Microsoft accounts only_ for the _Supported account types_ set Microsoft tenant to _consumers_ (`https://login.microsoftonline.com/consumers`).
|
||||
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
If your app is registered as _My organization only_ for the _Supported account types_ you may want to configure Supabase Auth with the organization's tenant URL. This will use the tenant's authorization flows instead, and will limit access at the Supabase Auth level to Microsoft accounts arising from only the specified tenant.
|
||||
|
||||
Configure this by storing a value under _Azure Tenant URL_ in the Supabase Auth provider configuration page for Azure that has the following format `https://login.microsoftonline.com/<tenant-id>`.
|
||||
|
||||
@@ -17,9 +17,9 @@ Setting up Notion logins for your application consists of 3 parts:
|
||||
## Create your notion integration
|
||||
|
||||
- Go to [developers.notion.com](https://developers.notion.com/).
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
- Click "View my integrations" and login.
|
||||
|
||||

|
||||

|
||||
|
||||
- Once logged in, go to [notion.so/my-integrations](https://notion.so/my-integrations) and create a new integration.
|
||||
- When creating your integration, ensure that you select "Public integration" under "Integration type" and "Read user information including email addresses" under "Capabilities".
|
||||
|
||||
@@ -141,7 +141,7 @@ project_id = "<id>"
|
||||
|
||||
<Admonition type="caution">
|
||||
|
||||
**Please follow this section carefully to prevent unauthorized access to your project's data when self-hosting.**
|
||||
**Follow this section carefully to prevent unauthorized access to your project's data when self-hosting.**
|
||||
|
||||
When using the Supabase hosted platform, following this step is optional.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ subtitle: 'Developing locally using the Supabase CLI.'
|
||||
sidebar_label: 'Overview'
|
||||
---
|
||||
|
||||
You can use the Supabase CLI to run the entire Supabase stack locally on your machine, simply by running `supabase init` and then `supabase start`. To install the CLI, see the [installation guide](/docs/guides/cli/getting-started#installing-the-supabase-cli).
|
||||
You can use the Supabase CLI to run the entire Supabase stack locally on your machine, by running `supabase init` and then `supabase start`. To install the CLI, see the [installation guide](/docs/guides/cli/getting-started#installing-the-supabase-cli).
|
||||
|
||||
The Supabase CLI provides tools to develop your project locally, deploy to the Supabase Platform, handle database migrations, and generate types directly from your database schema.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ title: 'Working With Arrays'
|
||||
description: 'How to use arrays in PostgreSQL and the Supabase API.'
|
||||
---
|
||||
|
||||
PostgreSQL supports flexible [array types](https://www.postgresql.org/docs/12/arrays.html). These arrays are also supported in the Supabase Dashboard and in the JavaScript API.
|
||||
Postgres supports flexible [array types](https://www.postgresql.org/docs/12/arrays.html). These arrays are also supported in the Supabase Dashboard and in the JavaScript API.
|
||||
|
||||
## Create a table with an array column
|
||||
|
||||
@@ -158,7 +158,7 @@ You should see:
|
||||
|
||||
## Query array data
|
||||
|
||||
PostgreSQL uses 1-based indexing (e.g., `textarray[1]` is the first item in the array).
|
||||
Postgres uses 1-based indexing (e.g., `textarray[1]` is the first item in the array).
|
||||
|
||||
<Tabs
|
||||
scrollable
|
||||
@@ -234,4 +234,4 @@ returns:
|
||||
|
||||
- [Supabase JS Client](https://github.com/supabase/supabase-js)
|
||||
- [Supabase - Get started for free](https://supabase.com)
|
||||
- [PostgreSQL Arrays](https://www.postgresql.org/docs/15/arrays.html)
|
||||
- [Postgres Arrays](https://www.postgresql.org/docs/15/arrays.html)
|
||||
@@ -159,7 +159,15 @@ supabase --experimental \
|
||||
postgres-config delete --config shared_buffers,work_mem
|
||||
```
|
||||
|
||||
By default, this might restart the database after deleting the configurations. You can use the `--no-restart` flag to prevent the restart:
|
||||
By default, changing the configuration, whether by updating or deleting, causes the database and all associated read replicas to restart. You can use the `--no-restart` flag to prevent this behavior, and attempt to reload the updated configuration without a restart. Refer to the Postgres documentation to determine if a given parameter can be reloaded without a restart.
|
||||
|
||||
<Admonition type="note" label="Read Replicas and Custom Config">
|
||||
|
||||
Postgres requires several parameters to be synchronized between the Primary cluster and [Read Replicas](/docs/guides/platform/read-replicas).
|
||||
|
||||
By default, Supabase ensures that this propagation is executed correctly. However, if the `--no-restart` behavior is used in conjunction with parameters that cannot be reloaded without a restart, the user is responsible for ensuring that both the primaries and the read replicas get restarted in a timely manner to ensure a stable running state. Leaving the configuration updated, but not utilized (via a restart) in such a case can result in read replica failure if the primary, or a read replica, restarts in isolation (e.g. due to an out-of-memory event, or hardware failure).
|
||||
|
||||
</Admonition>
|
||||
|
||||
```bash
|
||||
supabase --experimental \
|
||||
@@ -187,6 +195,6 @@ alter role "<role_name>" set "<setting_name>" to default;
|
||||
|
||||
### Considerations
|
||||
|
||||
1. Changes through the CLI might restart the database causing momentary disruption to existing database connections; in most cases this should not take more than a few seconds. However, you can use the --no-restart flag to bypass the restart and keep the connections intact. Keep in mind that this depends on the specific configuration changes you're making. if the change requires a restart, using the --no-restart flag will prevent the restart but you won't see those changes take effect until a restart is manually triggered.
|
||||
1. Changes through the CLI might restart the database causing momentary disruption to existing database connections; in most cases this should not take more than a few seconds. However, you can use the --no-restart flag to bypass the restart and keep the connections intact. Keep in mind that this depends on the specific configuration changes you're making. if the change requires a restart, using the --no-restart flag will prevent the restart but you won't see those changes take effect until a restart is manually triggered. Additionally, some parameters are required to be the same on Primary and Read Replicas; not restarting in these cases can result in read replica failure if the Primary/Read Replicas restart in isolation.
|
||||
1. Custom Postgres Config will always override the default optimizations generated by Supabase. When changing compute add-ons, you should also review and update your custom Postgres Config to ensure they remain compatible and effective with the updated compute.
|
||||
1. Some parameters (e.g. `wal_keep_size`) can increase disk utilization, triggering disk expansion, which in turn can lead to [increases in your bill](/docs/guides/platform/compute-add-ons#disk-io).
|
||||
@@ -22,7 +22,7 @@ The `http` extension allows you to call RESTful endpoints within Postgres.
|
||||
|
||||
Let's cover some basic concepts:
|
||||
|
||||
- REST: stands for REpresentational State Transfer. It's simply a way to request data from external services.
|
||||
- REST: stands for REpresentational State Transfer. It's a way to request data from external services.
|
||||
- RESTful APIs are servers which accept HTTP "calls". The calls are typically:
|
||||
- `GET` − Read only access to a resource.
|
||||
- `POST` − Creates a new resource.
|
||||
@@ -69,7 +69,7 @@ It's good practice to create the extension within a separate schema (like `exten
|
||||
|
||||
### Available functions
|
||||
|
||||
While the main usage is simply `http('http_request')`, there are 5 wrapper functions for specific functionality:
|
||||
While the main usage is `http('http_request')`, there are 5 wrapper functions for specific functionality:
|
||||
|
||||
- `http_get()`
|
||||
- `http_post()`
|
||||
|
||||
@@ -4,7 +4,7 @@ title: 'HypoPG: Hypothetical indexes'
|
||||
description: 'Quickly check if an index can be used without creating it.'
|
||||
---
|
||||
|
||||
`HypoPG` is PostgreSQL extension for creating hypothetical/virtual indexes. HypoPG allows users to rapidly create hypothetical/virtual indexes that have no resource cost (CPU, disk, memory) that are visible to the PostgreSQL query planner.
|
||||
`HypoPG` is Postgres extension for creating hypothetical/virtual indexes. HypoPG allows users to rapidly create hypothetical/virtual indexes that have no resource cost (CPU, disk, memory) that are visible to the Postgres query planner.
|
||||
|
||||
The motivation for HypoPG is to allow users to quickly search for an index to improve a slow query without consuming server resources or waiting for them to build.
|
||||
|
||||
@@ -62,7 +62,7 @@ from
|
||||
generate_series(1, 10000) id;
|
||||
```
|
||||
|
||||
We can generate an explain plan for a description of how the PostgreSQL query planner
|
||||
We can generate an explain plan for a description of how the Postgres query planner
|
||||
intends to execute the query.
|
||||
|
||||
{/* prettier-ignore */}
|
||||
@@ -78,7 +78,7 @@ explain select * from account where id=1;
|
||||
|
||||
Using HypoPG, we can create a hypothetical index on the `account(id)` column to check if it would be useful to the query planner and then re-run the explain plan.
|
||||
|
||||
Note that the virtual indexes created by HypoPG are only visible in the PostgreSQL connection that they were created in. Supabase connects to PostgreSQL through a connection pooler so the `hypopg_create_index` statement and the `explain` statement should be executed in a single query.
|
||||
Note that the virtual indexes created by HypoPG are only visible in the Postgres connection that they were created in. Supabase connects to Postgres through a connection pooler so the `hypopg_create_index` statement and the `explain` statement should be executed in a single query.
|
||||
|
||||
{/* prettier-ignore */}
|
||||
```sql
|
||||
|
||||
@@ -4,9 +4,9 @@ title: 'pg_graphql: GraphQL for PostgreSQL'
|
||||
description: 'A GraphQL Interface for PostgreSQL'
|
||||
---
|
||||
|
||||
[pg_graphql](https://supabase.github.io/pg_graphql/) is PostgreSQL extension for interacting with the database using [GraphQL](https://graphql.org) instead of SQL.
|
||||
[pg_graphql](https://supabase.github.io/pg_graphql/) is Postgres extension for interacting with the database using [GraphQL](https://graphql.org) instead of SQL.
|
||||
|
||||
The extension reflects a GraphQL schema from the existing SQL schema and exposes it through a SQL function, `graphql.resolve(...)`. This enables any programming language that can connect to PostgreSQL to query the database via GraphQL with no additional servers, processes, or libraries.
|
||||
The extension reflects a GraphQL schema from the existing SQL schema and exposes it through a SQL function, `graphql.resolve(...)`. This enables any programming language that can connect to Postgres to query the database via GraphQL with no additional servers, processes, or libraries.
|
||||
|
||||
The `pg_graphql` resolve method is designed to interop with [PostgREST](https://postgrest.org/en/stable/index.html), the tool that underpins the Supabase API, such that the `graphql.resolve` function can be called via RPC to safely and performantly expose the GraphQL API over HTTP/S.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ description: 'Validate json/jsonb with JSON Schema in PostgreSQL.'
|
||||
tocVideo: 'amJo48ChLGs'
|
||||
---
|
||||
|
||||
[JSON Schema](https://json-schema.org) is a language for annotating and validating JSON documents. [`pg_jsonschema`](https://github.com/supabase/pg_jsonschema) is a PostgreSQL extension that adds the ability to validate PostgreSQL's built-in `json` and `jsonb` data types against JSON Schema documents.
|
||||
[JSON Schema](https://json-schema.org) is a language for annotating and validating JSON documents. [`pg_jsonschema`](https://github.com/supabase/pg_jsonschema) is a Postgres extension that adds the ability to validate PostgreSQL's built-in `json` and `jsonb` data types against JSON Schema documents.
|
||||
|
||||
## Enable the extension
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ The pg_net API is in beta. Functions signatures may change.
|
||||
|
||||
</Admonition>
|
||||
|
||||
[pg_net](https://github.com/supabase/pg_net/) enables PostgreSQL to make asynchronous HTTP/HTTPS requests in SQL. It differs from the [`http`](https://supabase.com/docs/guides/database/extensions/http) extension in that it is asynchronous by default. This makes it useful in blocking functions (like triggers).
|
||||
[pg_net](https://github.com/supabase/pg_net/) enables Postgres to make asynchronous HTTP/HTTPS requests in SQL. It differs from the [`http`](https://supabase.com/docs/guides/database/extensions/http) extension in that it is asynchronous by default. This makes it useful in blocking functions (like triggers).
|
||||
|
||||
It eliminates the need for servers to continuously poll for database changes and instead allows the database to proactively notify external resources about significant events.
|
||||
|
||||
@@ -359,7 +359,7 @@ select
|
||||
|
||||
### Call an endpoint every minute with [pg_cron](https://supabase.com/docs/guides/database/extensions/pgcron)
|
||||
|
||||
The pg_cron extension enables PostgreSQL to become its own cron server. With it you can schedule regular calls with up to a minute precision to endpoints.
|
||||
The pg_cron extension enables Postgres to become its own cron server. With it you can schedule regular calls with up to a minute precision to endpoints.
|
||||
|
||||
```sql
|
||||
select cron.schedule(
|
||||
|
||||
@@ -4,7 +4,7 @@ title: 'pg_plan_filter: Restrict Total Cost'
|
||||
description: 'Block queries over a total cost limit'
|
||||
---
|
||||
|
||||
[`pg_plan_filter`](https://github.com/pgexperts/pg_plan_filter) is PostgreSQL extension to block execution of statements where query planner's estimate of the total cost exceeds a threshold. This is intended to give database administrators a way to restrict the contribution an individual query has on database load.
|
||||
[`pg_plan_filter`](https://github.com/pgexperts/pg_plan_filter) is Postgres extension to block execution of statements where query planner's estimate of the total cost exceeds a threshold. This is intended to give database administrators a way to restrict the contribution an individual query has on database load.
|
||||
|
||||
## Enable the extension
|
||||
|
||||
|
||||
@@ -345,15 +345,15 @@ To prevent PGAudit from monitoring the problematic roles, you'll want to change
|
||||
|
||||
## FAQ
|
||||
|
||||
#### Can I use PGAudit to debug database functions?
|
||||
#### Using PGAudit to debug database functions
|
||||
|
||||
Technically yes, but it is not the best approach. It is better to check out our [function debugging guide](https://supabase.com/docs/guides/database/functions#general-logging) instead.
|
||||
|
||||
#### How can I download database logs?
|
||||
#### Downloading database logs
|
||||
|
||||
In the [Logs Dashboard](https://supabase.com/dashboard/project/_/logs/postgres-logs) you can download logs as CSVs.
|
||||
|
||||
#### Can I log observed table rows?
|
||||
#### Logging observed table rows
|
||||
|
||||
By default, PGAudit records queries, but not the returned rows. You can modify this behavior with the `pgaudit.log_rows` variable:
|
||||
|
||||
@@ -367,7 +367,7 @@ alter role "postgres" set pgaudit.log_rows to 'off';
|
||||
|
||||
You should not do this unless you are _absolutely_ certain it is necessary for your use case. It can expose sensitive values to your logs that ideally should not be preserved. Furthermore, if done in excess, it can noticeably reduce database performance.
|
||||
|
||||
#### Can I log function parameters?
|
||||
#### Logging function parameters
|
||||
|
||||
We don't currently support configuring `pgaudit.log_parameter` because it may log secrets in encrypted columns if you are using [pgsodium](https://supabase.com/docs/guides/database/extensions/pgsodium) or[Vault](https://supabase.com/docs/guides/database/vault).
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ title: 'pgjwt: JSON Web Tokens'
|
||||
description: 'Encode and decode JWTs in PostgreSQL'
|
||||
---
|
||||
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
The [`pgjwt`](https://github.com/michelp/pgjwt) (PostgreSQL JSON Web Token) extension allows you to create and parse [JSON Web Tokens (JWTs)](https://en.wikipedia.org/wiki/JSON_Web_Token) within a PostgreSQL database. JWTs are commonly used for authentication and authorization in web applications and services.
|
||||
|
||||
## Enable the extension
|
||||
|
||||
@@ -5,7 +5,7 @@ description: 'Full Text Search for multiple languages in PostgreSQL'
|
||||
tocVideo: 'Mmmv9g_MiBA'
|
||||
---
|
||||
|
||||
`PGroonga` is a PostgreSQL extension adding a full text search indexing method based on [Groonga](https://groonga.org). While native PostgreSQL supports full text indexing, it is limited to alphabet and digit based languages. `PGroonga` offers a wider range of character support making it viable for a superset of languages supported by PostgreSQL including Japanese, Chinese, etc.
|
||||
`PGroonga` is a Postgres extension adding a full text search indexing method based on [Groonga](https://groonga.org). While native Postgres supports full text indexing, it is limited to alphabet and digit based languages. `PGroonga` offers a wider range of character support making it viable for a superset of languages supported by Postgres including Japanese, Chinese, etc.
|
||||
|
||||
## Enable the extension
|
||||
|
||||
@@ -71,7 +71,7 @@ values
|
||||
('There is groonga command.');
|
||||
```
|
||||
|
||||
The PostgreSQL query planner is smart enough to know that, for extremely small tables, it's faster to scan the whole table rather than loading an index. To force the index to be used, we can disable sequential scans:
|
||||
The Postgres query planner is smart enough to know that, for extremely small tables, it's faster to scan the whole table rather than loading an index. To force the index to be used, we can disable sequential scans:
|
||||
|
||||
{/* prettier-ignore */}
|
||||
```sql
|
||||
|
||||
@@ -4,7 +4,7 @@ title: 'pgrouting: Geospatial Routing'
|
||||
description: 'Extends PostGIS with Geospatial Routing'
|
||||
---
|
||||
|
||||
[`pgRouting`](http://pgrouting.org) is PostgreSQL and [PostGIS](http://postgis.net) extension adding geospatial routing functionality.
|
||||
[`pgRouting`](http://pgrouting.org) is Postgres and [PostGIS](http://postgis.net) extension adding geospatial routing functionality.
|
||||
|
||||
The core functionality of `pgRouting` is a set of path finding algorithms including:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ title: 'pgTAP: Unit Testing'
|
||||
description: 'Unit testing in PostgreSQL.'
|
||||
---
|
||||
|
||||
`pgTAP` is a unit testing extension for PostgreSQL.
|
||||
`pgTAP` is a unit testing extension for Postgres.
|
||||
|
||||
## Overview
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ title: 'pgvector: Embeddings and vector similarity'
|
||||
description: 'pgvector: a PostgreSQL extension for storing embeddings and performing vector similarity search.'
|
||||
---
|
||||
|
||||
[pgvector](https://github.com/pgvector/pgvector/) is a PostgreSQL extension for vector similarity search. It can also be used for storing [embeddings](https://supabase.com/blog/openai-embeddings-postgres-vector).
|
||||
[pgvector](https://github.com/pgvector/pgvector/) is a Postgres extension for vector similarity search. It can also be used for storing [embeddings](https://supabase.com/blog/openai-embeddings-postgres-vector).
|
||||
|
||||
<Admonition type="note">
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ title: 'plpgsql_check: PL/pgSQL Linter'
|
||||
description: 'Lint PL/pgSQL code'
|
||||
---
|
||||
|
||||
[plpgsql_check](https://github.com/okbob/plpgsql_check) is a PostgreSQL extension that lints plpgsql for syntax, semantic and other related issues. The tool helps developers to identify and correct errors before executing the code. plpgsql_check is most useful for developers who are working with large or complex SQL codebases, as it can help identify and resolve issues early in the development cycle.
|
||||
[plpgsql_check](https://github.com/okbob/plpgsql_check) is a Postgres extension that lints plpgsql for syntax, semantic and other related issues. The tool helps developers to identify and correct errors before executing the code. plpgsql_check is most useful for developers who are working with large or complex SQL codebases, as it can help identify and resolve issues early in the development cycle.
|
||||
|
||||
## Enable the extension
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ Procedural languages are automatically installed within `pg_catalog`, so you don
|
||||
|
||||
## Create `plv8` functions
|
||||
|
||||
Functions written in `plv8` are written just like any other PostgreSQL functions, only
|
||||
Functions written in `plv8` are written just like any other Postgres functions, only
|
||||
with the `language` identifier set to `plv8`.
|
||||
|
||||
```sql
|
||||
|
||||
@@ -202,7 +202,7 @@ We will create [database functions](https://supabase.com/docs/guides/database/fu
|
||||
|
||||
### Order by distance
|
||||
|
||||
Sorting datasets from closest to farthest, sometimes called nearest-neighbor sort, is a very common use case in Geo-queries. PostGIS can handle it very easily with the use of the [`<->`](https://postgis.net/docs/geometry_distance_knn.html) operator. `<->` operator returns the two-dimensional distance between two geometries and will utilize the spatial index when used within `order by` clause. You can create the following database function to sort the restaurants from closest to farthest by passing the current locations as parameters.
|
||||
Sorting datasets from closest to farthest, sometimes called nearest-neighbor sort, is a very common use case in Geo-queries. PostGIS can handle it with the use of the [`<->`](https://postgis.net/docs/geometry_distance_knn.html) operator. `<->` operator returns the two-dimensional distance between two geometries and will utilize the spatial index when used within `order by` clause. You can create the following database function to sort the restaurants from closest to farthest by passing the current locations as parameters.
|
||||
|
||||
```sql
|
||||
create or replace function nearby_restaurants(lat float, long float)
|
||||
|
||||
@@ -60,7 +60,7 @@ drop extension if exists rum;
|
||||
|
||||
#### For type: `tsvector`
|
||||
|
||||
To understand the following you may need first to see [Official PostgreSQL documentation on text
|
||||
To understand the following you may need first to see [Official Postgres documentation on text
|
||||
search](https://www.postgresql.org/docs/current/functions-textsearch.html)
|
||||
|
||||
`rum_tsvector_ops`
|
||||
|
||||
@@ -4,9 +4,9 @@ title: 'timescaledb: Time-Series data'
|
||||
description: 'Scalable time-series data storage and analysis'
|
||||
---
|
||||
|
||||
[`timescaledb`](https://docs.timescale.com/timescaledb/latest/) is a PostgreSQL extension designed for improved handling of time-series data. It provides a scalable, high-performance solution for storing and querying time-series data on top of a standard PostgreSQL database.
|
||||
[`timescaledb`](https://docs.timescale.com/timescaledb/latest/) is a Postgres extension designed for improved handling of time-series data. It provides a scalable, high-performance solution for storing and querying time-series data on top of a standard Postgres database.
|
||||
|
||||
`timescaledb` uses a time-series-aware storage model and indexing techniques to improve performance of PostgreSQL in working with time-series data. The extension divides data into chunks based on time intervals, allowing it to scale efficiently, especially for large data sets. The data is then compressed, optimized for write-heavy workloads, and partitioned for parallel processing. `timescaledb` also includes a set of functions, operators, and indexes that work with time-series data to reduce query times, and make data easier to work with.
|
||||
`timescaledb` uses a time-series-aware storage model and indexing techniques to improve performance of Postgres in working with time-series data. The extension divides data into chunks based on time intervals, allowing it to scale efficiently, especially for large data sets. The data is then compressed, optimized for write-heavy workloads, and partitioned for parallel processing. `timescaledb` also includes a set of functions, operators, and indexes that work with time-series data to reduce query times, and make data easier to work with.
|
||||
|
||||
<Admonition type="note">
|
||||
|
||||
|
||||
@@ -93,4 +93,4 @@ create table contacts (
|
||||
## Resources
|
||||
|
||||
- [Choosing a Postgres Primary Key](https://supabase.com/blog/choosing-a-postgres-primary-key)
|
||||
- [The Basics Of PostgreSQL `UUID` Data Type](https://www.postgresqltutorial.com/postgresql-uuid/)
|
||||
- [The Basics Of Postgres `UUID` Data Type](https://www.postgresqltutorial.com/postgresql-uuid/)
|
||||
@@ -7,7 +7,7 @@ subtitle: 'Connecting to external systems using Postgres Foreign Data Wrappers.'
|
||||
|
||||
Foreign Data Wrappers (FDW) are a core feature of Postgres that allow you to access and query data stored in external data sources as if they were native Postgres tables.
|
||||
|
||||
Postgres includes several built-in foreign data wrappers, such as [`postgres_fdw`](https://www.postgresql.org/docs/current/postgres-fdw.html) for accessing other PostgreSQL databases, and [`file_fdw`](https://www.postgresql.org/docs/current/file-fdw.html) for reading data from files. Supabase extends this feature to query other databases or any other external systems. We do this with our open source [Wrappers](https://github.com/supabase/wrappers) framework. In these guides we'll refer to them as "Wrappers", Foreign Data Wrappers, or FDWs. They are conceptually the same thing.
|
||||
Postgres includes several built-in foreign data wrappers, such as [`postgres_fdw`](https://www.postgresql.org/docs/current/postgres-fdw.html) for accessing other Postgres databases, and [`file_fdw`](https://www.postgresql.org/docs/current/file-fdw.html) for reading data from files. Supabase extends this feature to query other databases or any other external systems. We do this with our open source [Wrappers](https://github.com/supabase/wrappers) framework. In these guides we'll refer to them as "Wrappers", Foreign Data Wrappers, or FDWs. They are conceptually the same thing.
|
||||
|
||||
## Concepts
|
||||
|
||||
|
||||
@@ -831,7 +831,7 @@ data = client.from_('books').select().text_search('fts', "'little' & 'big'").exe
|
||||
|
||||
## Query operators
|
||||
|
||||
Visit [PostgreSQL: Text Search Functions and Operators](https://www.postgresql.org/docs/current/functions-textsearch.html)
|
||||
Visit [Postgres: Text Search Functions and Operators](https://www.postgresql.org/docs/current/functions-textsearch.html)
|
||||
to learn about additional query operators you can use to do more advanced `full text queries`, such as:
|
||||
|
||||
### Proximity: `<->` [#proximity]
|
||||
@@ -1058,4 +1058,4 @@ data = client.from_('books').select().text_search('description', "'big' & !'litt
|
||||
|
||||
## Resources
|
||||
|
||||
- [PostgreSQL: Text Search Functions and Operators](https://www.postgresql.org/docs/12/functions-textsearch.html)
|
||||
- [Postgres: Text Search Functions and Operators](https://www.postgresql.org/docs/12/functions-textsearch.html)
|
||||
@@ -599,8 +599,8 @@ select advanced_example();
|
||||
|
||||
- Official Client libraries: [JavaScript](../../reference/javascript/rpc) and [Flutter](../../reference/dart/rpc)
|
||||
- Community client libraries: [github.com/supabase-community](https://github.com/supabase-community)
|
||||
- PostgreSQL Official Docs: [Chapter 9. Functions and Operators](https://www.postgresql.org/docs/current/functions.html)
|
||||
- PostgreSQL Reference: [CREATE FUNCTION](https://www.postgresql.org/docs/9.1/sql-createfunction.html)
|
||||
- Postgres Official Docs: [Chapter 9. Functions and Operators](https://www.postgresql.org/docs/current/functions.html)
|
||||
- Postgres Reference: [CREATE FUNCTION](https://www.postgresql.org/docs/9.1/sql-createfunction.html)
|
||||
|
||||
## Deep dive
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ Supabase dashboard provides a user-friendly way to import data. However, for ver
|
||||
|
||||
### Option 2: Bulk import using pgloader
|
||||
|
||||
[pgloader](https://pgloader.io/) is a powerful tool for efficiently importing data into a PostgreSQL database that supports a wide range of source database engines, including MySQL and MS SQL.
|
||||
[pgloader](https://pgloader.io/) is a powerful tool for efficiently importing data into a Postgres database that supports a wide range of source database engines, including MySQL and MS SQL.
|
||||
|
||||
You can use it in conjunction with Supabase by following these steps:
|
||||
|
||||
@@ -126,4 +126,4 @@ To build an index after the data import:
|
||||
create index index_name on table_name (column_name);
|
||||
```
|
||||
|
||||
Read more about [Managing Indexes in PostgreSQL](/docs/guides/database/postgres/indexes).
|
||||
Read more about [Managing Indexes in Postgres](/docs/guides/database/postgres/indexes).
|
||||
@@ -257,6 +257,7 @@ If you run just `explain` without the `analyze` keyword, the database will only
|
||||
Using the query plan analyzer to optimize your queries is a large topic, with a number of online resources available:
|
||||
|
||||
- [Official docs.](https://www.postgresql.org/docs/current/using-explain.html)
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
- [The Art of PostgreSQL.](https://theartofpostgresql.com/explain-plan-visualizer/)
|
||||
- [Postgres Wiki.](https://wiki.postgresql.org/wiki/Using_EXPLAIN)
|
||||
- [Enterprise DB.](https://www.enterprisedb.com/blog/postgresql-query-optimization-performance-tuning-with-explain-analyze)
|
||||
|
||||
@@ -57,8 +57,7 @@ hideToc: true
|
||||
|
||||
<StepHikeCompact.Details title="Explore">
|
||||
|
||||
That's it! Explore your data in Metabase
|
||||
|
||||
Explore your data in Metabase
|
||||
</StepHikeCompact.Details>
|
||||
|
||||
<StepHikeCompact.Code>
|
||||
|
||||
@@ -6,7 +6,7 @@ description: "A storage extension for PostgreSQL which uses PostgreSQL's pluggab
|
||||
|
||||
The [OrioleDB](https://www.orioledb.com/) Postgres extension provides a drop-in replacement storage engine for the default heap storage method. It is designed to improve Postgres' scalability and performance.
|
||||
|
||||
OrioleDB addresses PostgreSQL's scalability limitations by removing bottlenecks in the shared memory cache under high concurrency. It also optimizes write-ahead-log (WAL) insertion through row-level WAL logging. These changes lead to significant improvements in the industry standard TPC-C benchmark, which approximates a real-world transactional workload. The following benchmark was performed on a c7g.metal instance and shows OrioleDB's performance outperforming the default PostgreSQL heap method with a 3.3x speedup.
|
||||
OrioleDB addresses PostgreSQL's scalability limitations by removing bottlenecks in the shared memory cache under high concurrency. It also optimizes write-ahead-log (WAL) insertion through row-level WAL logging. These changes lead to significant improvements in the industry standard TPC-C benchmark, which approximates a real-world transactional workload. The following benchmark was performed on a c7g.metal instance and shows OrioleDB's performance outperforming the default Postgres heap method with a 3.3x speedup.
|
||||
|
||||
<Image
|
||||
alt="TPC-C (warehouses = 500)"
|
||||
@@ -37,7 +37,7 @@ Multi-Version Concurrency Control (MVCC) is implemented using an undo log. The u
|
||||
|
||||
### Copy-on-write checkpoints
|
||||
|
||||
OrioleDB implements copy-on-write checkpoints to persist data efficiently. This approach writes only modified data during a checkpoint, reducing the I/O overhead compared to traditional PostgreSQL checkpointing and allowing row-level WAL logging.
|
||||
OrioleDB implements copy-on-write checkpoints to persist data efficiently. This approach writes only modified data during a checkpoint, reducing the I/O overhead compared to traditional Postgres checkpointing and allowing row-level WAL logging.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -77,14 +77,18 @@ You can enable Postgres extensions with the click of a button within the Supabas
|
||||
|
||||
## Terminology
|
||||
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
|
||||
### Postgres or PostgreSQL?
|
||||
|
||||
PostgreSQL the database was derived from the POSTGRES Project, a package written at the University of California at Berkeley in 1986.
|
||||
This package included a query language called "PostQUEL".
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
|
||||
PostgreSQL the database was derived from the POSTGRES Project, a package written at the University of California at Berkeley in 1986.This package included a query language called "PostQUEL".
|
||||
|
||||
In 1994, Postgres95 was built on top of POSTGRES code, adding an SQL language interpreter as a replacement for PostQUEL.
|
||||
Eventually, Postgres95 was renamed to PostgreSQL to reflect the SQL query capability.
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
|
||||
Eventually, Postgres95 was renamed to PostgreSQL to reflect the SQL query capability.
|
||||
After this, many people referred to it as Postgres since it's less prone to confusion. Supabase is all about simplicity, so we also refer to it as Postgres.
|
||||
|
||||
## Tips
|
||||
|
||||
@@ -39,7 +39,7 @@ However, this gives the post owner full access to update the row, including all
|
||||
|
||||
To restrict access to columns, you can use [Privileges](https://www.postgresql.org/docs/current/ddl-priv.html).
|
||||
|
||||
There are two types of privileges in PostgreSQL:
|
||||
There are two types of privileges in Postgres:
|
||||
|
||||
1. **table-level**: Grants the privilege on all columns in the table.
|
||||
2. **column-level** Grants the privilege on a specific column in the table.
|
||||
|
||||
@@ -21,7 +21,7 @@ This data can further be used in conjunction with the [`explain`](https://www.po
|
||||
## Managing timezones
|
||||
|
||||
Every Supabase database is set to UTC timezone by default. We strongly recommend keeping it this way, even if your users are in a different location.
|
||||
This is because it makes it much easier to calculate differences between timezones if you adopt the mental model that "everything in my database is in UTC time."
|
||||
This is because it makes it much easier to calculate differences between timezones if you adopt the mental model that everything in your database is in UTC time.
|
||||
|
||||
### Change timezone
|
||||
|
||||
|
||||
+1
-1
@@ -200,7 +200,7 @@ using (true)
|
||||
|
||||
### Enable the hook
|
||||
|
||||
In the dashboard, navigate to [`Authentication > Hooks (Beta)`](/dashboard/project/_/auth/hooks) and select the appropriate PostgreSQL function from the dropdown menu.
|
||||
In the dashboard, navigate to [`Authentication > Hooks (Beta)`](/dashboard/project/_/auth/hooks) and select the appropriate Postgres function from the dropdown menu.
|
||||
|
||||
When developing locally, follow the [local development](/docs/guides/auth/auth-hooks#local-development) instructions.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Postgres manages database access permissions using the concept of roles. General
|
||||
|
||||
## Users vs roles
|
||||
|
||||
In PostgreSQL, roles can function as users or groups of users. Users are roles with login privileges, while groups (also known as role groups) are roles that don't have login privileges but can be used to manage permissions for multiple users.
|
||||
In Postgres, roles can function as users or groups of users. Users are roles with login privileges, while groups (also known as role groups) are roles that don't have login privileges but can be used to manage permissions for multiple users.
|
||||
|
||||
## Creating roles
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ Using the `anon` Postgres role is different from an [anonymous user](/docs/guide
|
||||
|
||||
## Creating policies
|
||||
|
||||
Policies are simply SQL logic that you attach to a Postgres table. You can attach as many policies as you want to each table.
|
||||
Policies are SQL logic that you attach to a Postgres table. You can attach as many policies as you want to each table.
|
||||
|
||||
Supabase provides some [helpers](#helper-functions) that simplify RLS if you're using Supabase Auth. We'll use these helpers to illustrate some basic policies:
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ footerHelpType: 'postgres'
|
||||
For this example, you will need:
|
||||
|
||||
- A Supabase project
|
||||
- A PostgreSQL database (running v10 or newer)
|
||||
- A Postgres database (running v10 or newer)
|
||||
|
||||
You will be running commands on both of these databases to publish changes from the Supabase database to the external database.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: 'Useful snippet for finding out which version of postgres you are r
|
||||
footerHelpType: 'postgres'
|
||||
---
|
||||
|
||||
It's important to know which version of PostgreSQL you are running as each major version has different features and may cause breaking changes. You may also need to update your schema when [upgrading](https://www.postgresql.org/docs/current/pgupgrade.html) or downgrading to a major Postgres version.
|
||||
It's important to know which version of Postgres you are running as each major version has different features and may cause breaking changes. You may also need to update your schema when [upgrading](https://www.postgresql.org/docs/current/pgupgrade.html) or downgrading to a major Postgres version.
|
||||
|
||||
Run the following query using the [SQL Editor](https://supabase.com/dashboard/project/_/sql) in the Supabase Dashboard:
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ You must define the "data type" when you create a column.
|
||||
|
||||
### Data types
|
||||
|
||||
Every column is a predefined type. PostgreSQL provides many [default types](https://www.postgresql.org/docs/current/datatype.html), and you can even design your own (or use extensions) if the default types don't fit your needs. You can use any data type that Postgres supports via the SQL editor. We only support a subset of these in the Table Editor in an effort to keep the experience simple for people with less experience with databases.
|
||||
Every column is a predefined type. Postgres provides many [default types](https://www.postgresql.org/docs/current/datatype.html), and you can even design your own (or use extensions) if the default types don't fit your needs. You can use any data type that Postgres supports via the SQL editor. We only support a subset of these in the Table Editor in an effort to keep the experience simple for people with less experience with databases.
|
||||
|
||||
<details>
|
||||
<summary>Show/Hide default data types</summary>
|
||||
@@ -122,7 +122,7 @@ Every column is a predefined type. PostgreSQL provides many [default types](http
|
||||
| `money` | | currency amount |
|
||||
| `numeric` | `decimal` | exact numeric of selectable precision |
|
||||
| `path` | | geometric path on a plane |
|
||||
| `pg_lsn` | | PostgreSQL Log Sequence Number |
|
||||
| `pg_lsn` | | Postgres Log Sequence Number |
|
||||
| `pg_snapshot` | | user-level transaction ID snapshot |
|
||||
| `point` | | geometric point on a plane |
|
||||
| `polygon` | | closed geometric path on a plane |
|
||||
@@ -320,7 +320,7 @@ psql -h DATABASE_URL -p 5432 -d postgres -U postgres \
|
||||
-c "\COPY movies FROM './movies.csv';"
|
||||
```
|
||||
|
||||
Additionally use the `DELIMITER`, `HEADER` and `FORMAT` options as defined in the PostgreSQL [COPY](https://www.postgresql.org/docs/current/sql-copy.html) docs.
|
||||
Additionally use the `DELIMITER`, `HEADER` and `FORMAT` options as defined in the Postgres [COPY](https://www.postgresql.org/docs/current/sql-copy.html) docs.
|
||||
|
||||
```bash
|
||||
psql -h DATABASE_URL -p 5432 -d postgres -U postgres \
|
||||
@@ -569,7 +569,7 @@ Without a view, we would need to go into every dependent query to add the new ru
|
||||
|
||||
#### Logical organization
|
||||
|
||||
With views, we can give our query a name. This is extremely useful for teams working with the same database. Instead of guessing what a query is supposed to do, a well-named view can easily explain it. For example, by looking at the name of the view **transcripts**, we can infer that the underlying query might involve the **students**, **courses**, and **grades** tables.
|
||||
With views, we can give our query a name. This is extremely useful for teams working with the same database. Instead of guessing what a query is supposed to do, a well-named view can explain it. For example, by looking at the name of the view **transcripts**, we can infer that the underlying query might involve the **students**, **courses**, and **grades** tables.
|
||||
|
||||
#### Security
|
||||
|
||||
@@ -621,6 +621,6 @@ Creating a materialized view is not a solution to inefficient queries. You shoul
|
||||
|
||||
- [Official Docs: Create table](https://www.postgresql.org/docs/current/sql-createtable.html)
|
||||
- [Official Docs: Create view](https://www.postgresql.org/docs/12/sql-createview.html)
|
||||
- [PostgreSQL Tutorial: Create tables](https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-create-table/)
|
||||
- [PostgreSQL Tutorial: Add column](https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-add-column/)
|
||||
- [PostgreSQL Tutorial: Views](https://www.postgresqltutorial.com/postgresql-views/)
|
||||
- [Postgres Tutorial: Create tables](https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-create-table/)
|
||||
- [Postgres Tutorial: Add column](https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-add-column/)
|
||||
- [Postgres Tutorial: Views](https://www.postgresqltutorial.com/postgresql-views/)
|
||||
@@ -82,4 +82,4 @@ Logging history of webhook calls is available under the `net` schema of your dat
|
||||
|
||||
## Resources
|
||||
|
||||
- [pg_net](/docs/guides/database/extensions/pgnet): an async networking extension for PostgreSQL
|
||||
- [pg_net](/docs/guides/database/extensions/pgnet): an async networking extension for Postgres
|
||||
@@ -4,7 +4,7 @@ description: 'Use Supabase Branches to test and preview changes.'
|
||||
subtitle: 'Use Supabase Branches to test and preview changes'
|
||||
---
|
||||
|
||||
Use branching to safely and easily experiment with changes to your Supabase project.
|
||||
Use branching to safely experiment with changes to your Supabase project.
|
||||
|
||||
Supabase branches work like Git branches. They let you create and test changes like new configurations, database schemas, or features in a separate, temporary instance without affecting your production setup.
|
||||
|
||||
@@ -505,7 +505,7 @@ When Branching is enabled, your `config.toml` settings automatically sync to all
|
||||
|
||||
### Basic configuration
|
||||
|
||||
To update configuration for a Supabase branch, simply modify `config.toml` and push to git. The Supabase integration will detect the changes and apply them to the corresponding branch.
|
||||
To update configuration for a Supabase branch, modify `config.toml` and push to git. The Supabase integration will detect the changes and apply them to the corresponding branch.
|
||||
|
||||
### Remote-specific configuration
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ After developing your project and deciding it's Production Ready, you should run
|
||||
|
||||
### Abuse prevention
|
||||
|
||||
- Supabase provides CAPTCHA protection on the signup, sign-in and password reset endpoints. Please refer to [our guide](/docs/guides/auth/auth-captcha) on how to protect against abuse using this method.
|
||||
- Supabase provides CAPTCHA protection on the signup, sign-in and password reset endpoints. Refer to [our guide](/docs/guides/auth/auth-captcha) on how to protect against abuse using this method.
|
||||
|
||||
### Email link validity
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ None of these are right or wrong. It depends on the stage of your project. You _
|
||||
|
||||
Supabase isn't a silver-bullet for bad architectural decisions. A poorly designed database will run poorly, no matter where it’s hosted.
|
||||
|
||||
You can get away with a poorly-designed database for a while by simply adding compute. After a while, things will start to break. The database schema is the area you want to spend _the most_ time thinking about. That’s the benefit of Supabase - you can spend more time designing a scalable database system and less time thinking about the mundane tasks like implementing CRUD APIs.
|
||||
You can get away with a poorly-designed database for a while by adding compute. After a while, things will start to break. The database schema is the area you want to spend _the most_ time thinking about. That’s the benefit of Supabase - you can spend more time designing a scalable database system and less time thinking about the mundane tasks like implementing CRUD APIs.
|
||||
|
||||
If you don’t want to implement logic inside your database, that is 100% fine. You can use _any_ tools which work with Postgres.
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ description: 'Write your functions using Dart.'
|
||||
|
||||
<Admonition type="caution">
|
||||
|
||||
Please be aware that the Dart Edge project is currently not actively maintained due to numerous breaking changes in Dart's development of (WASM) support.
|
||||
Be aware that the Dart Edge project is currently not actively maintained due to numerous breaking changes in Dart's development of (WASM) support.
|
||||
|
||||
</Admonition>
|
||||
|
||||
[Dart Edge](https://docs.dartedge.dev/) is an experimental project that enables you to write Supabase Edge Functions using Dart. It's built and maintained by [Invertase](https://invertase.io/).
|
||||
|
||||
For detailed information on how to set up and use Dart Edge with Supabase, please refer to the [official Dart Edge documentation for Supabase](https://invertase.docs.page/dart_edge/platform/supabase).
|
||||
For detailed information on how to set up and use Dart Edge with Supabase, refer to the [official Dart Edge documentation for Supabase](https://invertase.docs.page/dart_edge/platform/supabase).
|
||||
@@ -147,4 +147,4 @@ supabase functions deploy amazon-bedrock
|
||||
supabase secrets set --env-file supabase/.env
|
||||
```
|
||||
|
||||
That's it, you've now deployed a serverless function that uses AI to generate and upload images to your Supabase storage bucket.
|
||||
You've now deployed a serverless function that uses AI to generate and upload images to your Supabase storage bucket.
|
||||
+1
-1
@@ -294,7 +294,7 @@ Set the secrets from the `.env` file:
|
||||
supabase secrets set --env-file supabase/functions/.env
|
||||
```
|
||||
|
||||
That's it, now your Supabase Edge Function will be triggered anytime an Auth Email needs to be send to the user!
|
||||
Now your Supabase Edge Function will be triggered anytime an Auth Email needs to be send to the user!
|
||||
|
||||
## More resources
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ video: 'https://www.youtube.com/v/J24Bvo_m7DM'
|
||||
3. Name your application and click on **Create**.
|
||||
4. Go to **Bot** section, click on **Add Bot**, and finally on **Yes, do it!** to confirm.
|
||||
|
||||
That's it. A new application is created which will hold our Slash Command. Don't close the tab as we need information from this application page throughout our development.
|
||||
A new application is created which will hold our Slash Command. Don't close the tab as we need information from this application page throughout our development.
|
||||
|
||||
Before we can write some code, we need to curl a discord endpoint to register a Slash Command in our app.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ tocVideo: 'w4Rr_1whU-U'
|
||||
|
||||
[Semantic search](/docs/guides/ai/semantic-search) interprets the meaning behind user queries rather than exact [keywords](/docs/guides/ai/keyword-search). It uses machine learning to capture the intent and context behind the query, handling language nuances like synonyms, phrasing variations, and word relationships.
|
||||
|
||||
Since Supabase Edge Runtime [v1.36.0](https://github.com/supabase/edge-runtime/releases/tag/v1.36.0) you can run the [`gte-small` model](https://huggingface.co/Supabase/gte-small) natively within Supabase Edge Functions without any external dependencies! This allows you to easily generate text embeddings without calling any external APIs!
|
||||
Since Supabase Edge Runtime [v1.36.0](https://github.com/supabase/edge-runtime/releases/tag/v1.36.0) you can run the [`gte-small` model](https://huggingface.co/Supabase/gte-small) natively within Supabase Edge Functions without any external dependencies! This allows you to generate text embeddings without calling any external APIs!
|
||||
|
||||
In this tutorial you're implementing three parts:
|
||||
|
||||
@@ -126,4 +126,4 @@ Deno.serve(async (req) => {
|
||||
})
|
||||
```
|
||||
|
||||
That's it, you now have AI powered semantic search set up without any external dependencies! Just you, pgvector, and Supabase Edge Functions!
|
||||
You now have AI powered semantic search set up without any external dependencies! Just you, pgvector, and Supabase Edge Functions!
|
||||
@@ -3,7 +3,7 @@ title: 'Monitoring with Sentry'
|
||||
description: 'Monitor Edge Functions with the Sentry Deno SDK.'
|
||||
---
|
||||
|
||||
Add the [Sentry Deno SDK](https://docs.sentry.io/platforms/javascript/guides/deno/) to your Supabase Edge Functions to easily track exceptions and get notified of errors or performance issues.
|
||||
Add the [Sentry Deno SDK](https://docs.sentry.io/platforms/javascript/guides/deno/) to your Supabase Edge Functions to track exceptions and get notified of errors or performance issues.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
|
||||
@@ -13,3 +13,9 @@ description: 'Handling signed Stripe Webhooks with Edge Functions.'
|
||||
</div>
|
||||
|
||||
Handling signed Stripe Webhooks with Edge Functions. [View on GitHub](https://github.com/supabase/supabase/blob/master/examples/edge-functions/supabase/functions/stripe-webhooks/index.ts).
|
||||
|
||||
<$CodeSample
|
||||
path="edge-functions/supabase/functions/stripe-webhooks/index.ts"
|
||||
lines={[[1, -1]]}
|
||||
meta="index.ts"
|
||||
/>
|
||||
@@ -17,7 +17,7 @@ When using VSCode, you should install both the Deno CLI and the the Deno languag
|
||||
|
||||
<Admonition type="tip">
|
||||
|
||||
The Supabase CLI can automatically create helpful Deno settings when running `supabase init`. Simply select `y` when prompted "Generate VS Code settings for Deno? [y/N]"!
|
||||
The Supabase CLI can automatically create helpful Deno settings when running `supabase init`. Select `y` when prompted "Generate VS Code settings for Deno? [y/N]"!
|
||||
|
||||
</Admonition>
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ Check out the [CLI Docs](/docs/guides/cli) to learn how to install the Supabase
|
||||
|
||||
<Admonition type="tip">
|
||||
|
||||
If you're using VS code you can have the CLI automatically create helpful Deno settings when running `supabase init`. Simply select `y` when prompted "Generate VS Code settings for Deno? [y/N]"!
|
||||
If you're using VS code you can have the CLI automatically create helpful Deno settings when running `supabase init`. Select `y` when prompted "Generate VS Code settings for Deno? [y/N]"!
|
||||
|
||||
</Admonition>
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ select
|
||||
url:= (select decrypted_secret from vault.decrypted_secrets where name = 'project_url') || '/functions/v1/function-name',
|
||||
headers:=jsonb_build_object(
|
||||
'Content-type', 'application/json',
|
||||
'Authorization', 'Bearer: ' || (select decrypted_secret from vault.decrypted_secrets where name = 'anon_key')
|
||||
'Authorization', 'Bearer ' || (select decrypted_secret from vault.decrypted_secrets where name = 'anon_key')
|
||||
),
|
||||
body:=concat('{"time": "', now(), '"}')::jsonb
|
||||
) as request_id;
|
||||
|
||||
@@ -18,7 +18,7 @@ Edge Functions have access to these secrets by default:
|
||||
- `SUPABASE_URL`: The API gateway for your Supabase project.
|
||||
- `SUPABASE_ANON_KEY`: The `anon` key for your Supabase API. This is safe to use in a browser when you have [Row Level Security](/docs/guides/database/postgres/row-level-security) enabled.
|
||||
- `SUPABASE_SERVICE_ROLE_KEY`: The `service_role` key for your Supabase API. This is safe to use in Edge Functions, but it should NEVER be used in a browser. This key will bypass [Row Level Security](/docs/guides/database/postgres/row-level-security).
|
||||
- `SUPABASE_DB_URL`: The URL for your [PostgreSQL database](/docs/guides/database). You can use this to connect directly to your database.
|
||||
- `SUPABASE_DB_URL`: The URL for your [Postgres database](/docs/guides/database). You can use this to connect directly to your database.
|
||||
|
||||
## Local secrets
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ The 546 error response might occur because:
|
||||
- Run the serve command with the `-debug` flag.
|
||||
- Support engineers can then try to run the provided sample code locally and see if they can reproduce the issue.
|
||||
- Search the [Edge Runtime](https://github.com/supabase/edge-runtime) and [CLI](https://github.com/supabase/cli) repos for the error message, to see if it has been reported before.
|
||||
- If the output from the commands above does not help you to resolve the issue, please open a support ticket via the Supabase Dashboard (by clicking the "Help" button at the top right) and include all output and details about your commands.
|
||||
- If the output from the commands above does not help you to resolve the issue, open a support ticket via the Supabase Dashboard (by clicking the "Help" button at the top right) and include all output and details about your commands.
|
||||
|
||||
## Advanced techniques
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ This test case consists of two parts. The first part tests the client library an
|
||||
|
||||
<Admonition type="note">
|
||||
|
||||
Please make sure to replace the placeholders (`supabaseUrl`, `supabaseKey`, `my_table`) with the actual values relevant to your Supabase setup.
|
||||
Make sure to replace the placeholders (`supabaseUrl`, `supabaseKey`, `my_table`) with the actual values relevant to your Supabase setup.
|
||||
|
||||
</Admonition>
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@ Each Supabase project consists of several tools:
|
||||
}}
|
||||
/>
|
||||
|
||||
### PostgreSQL (database)
|
||||
### Postgres (database)
|
||||
|
||||
PostgreSQL is the core of Supabase. We do not abstract the PostgreSQL database—you can access it and use it with full privileges. We simply provide tools which makes PostgreSQL as easy to use as Firebase.
|
||||
Postgres is the core of Supabase. We do not abstract the Postgres database—you can access it and use it with full privileges. We provide tools which makes Postgres as easy to use as Firebase.
|
||||
|
||||
- Official Docs: [postgresql.org/docs](https://www.postgresql.org/docs/current/index.html)
|
||||
- Source code: [github.com/postgres/postgres](https://github.com/postgres/postgres) (mirror)
|
||||
- License: [PostgreSQL License](https://www.postgresql.org/about/licence/)
|
||||
- Language: C
|
||||
{/* supa-mdx-lint-disable-next-line Rule004ExcludeWords */}
|
||||
- License: [PostgreSQL License](https://www.postgresql.org/about/licence/)- Language: C
|
||||
|
||||
### Studio (dashboard)
|
||||
|
||||
@@ -56,7 +56,7 @@ A JWT-based API for managing users and issuing access tokens. This integrates wi
|
||||
|
||||
### PostgREST (API)
|
||||
|
||||
A standalone web server that turns your PostgreSQL database directly into a RESTful API.
|
||||
A standalone web server that turns your Postgres database directly into a RESTful API.
|
||||
We use this with our [`pg_graphql`](https://github.com/supabase/pg_graphql) extension to provide a GraphQL API.
|
||||
|
||||
- Official Docs: [postgrest.org](https://postgrest.org/)
|
||||
|
||||
@@ -110,9 +110,9 @@ hideToc: true
|
||||
|
||||
<StepHikeCompact.Step step={6}>
|
||||
<StepHikeCompact.Details title="Update your Prisma Schema">
|
||||
By default, RedwoodJS ships with a SQLite database, but we want to use PostgreSQL.
|
||||
By default, RedwoodJS ships with a SQLite database, but we want to use Postgres.
|
||||
|
||||
Update your Prisma schema file `api/db/schema.prisma` to use your Supabase PostgreSQL database connection environment variables you setup in Step 5.
|
||||
Update your Prisma schema file `api/db/schema.prisma` to use your Supabase Postgres database connection environment variables you setup in Step 5.
|
||||
</StepHikeCompact.Details>
|
||||
|
||||
<StepHikeCompact.Code>
|
||||
|
||||
@@ -73,7 +73,7 @@ These variables are safe to expose in your Expo app since Supabase has
|
||||
|
||||
If you wish to encrypt the user's session information, you can use `aes-js` and store the encryption key in [Expo SecureStore](https://docs.expo.dev/versions/latest/sdk/securestore). The [`aes-js` library](https://github.com/ricmoo/aes-js) is a reputable JavaScript-only implementation of the AES encryption algorithm in CTR mode. A new 256-bit encryption key is generated using the `react-native-get-random-values` library. This key is stored inside Expo's SecureStore, while the value is encrypted and placed inside AsyncStorage.
|
||||
|
||||
Please make sure that:
|
||||
Make sure that:
|
||||
- You keep the `expo-secure-storage`, `aes-js` and `react-native-get-random-values` libraries up-to-date.
|
||||
- Choose the correct [`SecureStoreOptions`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestoreoptions) for your app's needs. E.g. [`SecureStore.WHEN_UNLOCKED`](https://docs.expo.dev/versions/latest/sdk/securestore/#securestorewhen_unlocked) regulates when the data can be accessed.
|
||||
- Carefully consider optimizations or other modifications to the above example, as those can lead to introducing subtle security vulnerabilities.
|
||||
|
||||
@@ -109,7 +109,7 @@ Local development with Supabase allows you to work on your projects in a self-co
|
||||
|
||||
To get started with local development, you'll need to install the [Supabase CLI](#cli) and Docker. The Supabase CLI allows you to start and manage your local Supabase stack, while Docker is used to run the necessary services.
|
||||
|
||||
Once set up, you can initialize a new Supabase project, start the local stack, and begin developing your application using local Supabase services. This includes access to a local PostgreSQL database, Auth, Storage, and other Supabase features.
|
||||
Once set up, you can initialize a new Supabase project, start the local stack, and begin developing your application using local Supabase services. This includes access to a local Postgres database, Auth, Storage, and other Supabase features.
|
||||
|
||||
## CLI
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ The Supabase CLI uses [Inbucket](https://github.com/inbucket/inbucket) to captur
|
||||
|
||||
### Accessing Inbucket
|
||||
|
||||
By default, Inbucket is available at [localhost:54324](http://localhost:54324) when you run `supabase start`. Simply open this URL in your browser to view the emails.
|
||||
By default, Inbucket is available at [localhost:54324](http://localhost:54324) when you run `supabase start`. Open this URL in your browser to view the emails.
|
||||
|
||||
### Going into production
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Testing is a critical part of database development, especially when working with
|
||||
|
||||
### Database unit testing with pgTAP
|
||||
|
||||
[pgTAP](https://pgtap.org) is a unit testing framework for PostgreSQL that allows testing:
|
||||
[pgTAP](https://pgtap.org) is a unit testing framework for Postgres that allows testing:
|
||||
|
||||
- Database structure: tables, columns, constraints
|
||||
- Row Level Security (RLS) policies
|
||||
|
||||
Loaded 100 of 292 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user