Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: Add schema qualified object references throughout the docs (#39904)

Tyler5cfc390a6a4d
diff --git a/apps/docs/content/guides/ai/engineering-for-scale.mdx b/apps/docs/content/guides/ai/engineering-for-scale.mdx
index f0e5e5be6a0..8159a4b1465 100644
--- a/apps/docs/content/guides/ai/engineering-for-scale.mdx
+++ b/apps/docs/content/guides/ai/engineering-for-scale.mdx
@@ -110,7 +110,7 @@ We can now create a foreign table to access the data in our secondary project.
```sql
create foreign table docs (
id text not null,
- embedding vector(384),
+ embedding extensions.vector(384),
metadata jsonb,
url text
)
diff --git a/apps/docs/content/guides/ai/examples/mixpeek-video-search.mdx b/apps/docs/content/guides/ai/examples/mixpeek-video-search.mdx
index ff8b7bafdb0..f2f1efc62cb 100644
--- a/apps/docs/content/guides/ai/examples/mixpeek-video-search.mdx
+++ b/apps/docs/content/guides/ai/examples/mixpeek-video-search.mdx
@@ -84,7 +84,7 @@ def seed():
"id": "text",
"start_time": "float8",
"end_time": "float8",
- "embedding": "vector(768)",
+ "embedding": "extensions.vector(768)",
"metadata": "jsonb"
})
diff --git a/apps/docs/content/guides/ai/examples/nextjs-vector-search.mdx b/apps/docs/content/guides/ai/examples/nextjs-vector-search.mdx
index 741680e583a..7bd534938ab 100644
--- a/apps/docs/content/guides/ai/examples/nextjs-vector-search.mdx
+++ b/apps/docs/content/guides/ai/examples/nextjs-vector-search.mdx
@@ -130,7 +130,7 @@ Let's prepare the database schema. We can use the "OpenAI Vector Search" quickst
page_id bigint not null references public.nods_page on delete cascade,
content text,
token_count int,
- embedding vector(1536),
+ embedding extensions.vector(1536),
slug text,
heading text
);
@@ -156,7 +156,7 @@ Let's prepare the database schema. We can use the "OpenAI Vector Search" quickst
```sql
-- Create embedding similarity search functions
create or replace function match_page_sections(
- embedding vector(1536),
+ embedding extensions.vector(1536),
match_threshold float,
match_count int,
min_content_length int
diff --git a/apps/docs/content/guides/ai/hybrid-search.mdx b/apps/docs/content/guides/ai/hybrid-search.mdx
index 8c53309df9d..de1dafe897c 100644
--- a/apps/docs/content/guides/ai/hybrid-search.mdx
+++ b/apps/docs/content/guides/ai/hybrid-search.mdx
@@ -53,7 +53,7 @@ create table documents (
id bigint primary key generated always as identity,
content text,
fts tsvector generated always as (to_tsvector('english', content)) stored,
- embedding vector(512)
+ embedding extensions.vector(512)
);
```
@@ -83,7 +83,7 @@ Finally we'll create our `hybrid_search` function:
```sql
create or replace function hybrid_search(
query_text text,
- query_embedding vector(512),
+ query_embedding extensions.vector(512),
match_count int,
full_text_weight float = 1,
semantic_weight float = 1,
@@ -158,7 +158,7 @@ select
from
hybrid_search(
'Italian recipes with tomato sauce', -- user query
- '[...]'::vector(512), -- embedding generated from user query
+ '[...]'::extensions.vector(512), -- embedding generated from user query
10
);
```
diff --git a/apps/docs/content/guides/ai/langchain.mdx b/apps/docs/content/guides/ai/langchain.mdx
index a25168eb31c..bb950bab43d 100644
--- a/apps/docs/content/guides/ai/langchain.mdx
+++ b/apps/docs/content/guides/ai/langchain.mdx
@@ -36,12 +36,12 @@ create table documents (
id bigserial primary key,
content text, -- corresponds to Document.pageContent
metadata jsonb, -- corresponds to Document.metadata
- embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
+ embedding extensions.vector(1536) -- 1536 works for OpenAI embeddings, change if needed
);
-- Create a function to search for documents
create function match_documents (
- query_embedding vector(1536),
+ query_embedding extensions.vector(1536),
match_count int default null,
filter jsonb DEFAULT '{}'
) returns table (
diff --git a/apps/docs/content/guides/ai/rag-with-permissions.mdx b/apps/docs/content/guides/ai/rag-with-permissions.mdx
index 20156f36c2e..763952e2974 100644
--- a/apps/docs/content/guides/ai/rag-with-permissions.mdx
+++ b/apps/docs/content/guides/ai/rag-with-permissions.mdx
@@ -29,7 +29,7 @@ create table document_sections (
id bigint primary key generated always as identity,
document_id bigint not null references documents (id),
content text not null,
- embedding vector (384)
+ embedding extensions.vector (384)
);
```
@@ -176,7 +176,7 @@ create table document_sections (
id bigint primary key generated always as identity,
document_id bigint not null,
content text not null,
- embedding vector (384)
+ embedding extensions.vector (384)
);
```
diff --git a/apps/docs/content/guides/ai/semantic-search.mdx b/apps/docs/content/guides/ai/semantic-search.mdx
index 7310323494e..8052f85050c 100644
--- a/apps/docs/content/guides/ai/semantic-search.mdx
+++ b/apps/docs/content/guides/ai/semantic-search.mdx
@@ -48,7 +48,7 @@ To implement semantic search in Postgres we use `pgvector` - an extension that a
create table documents (
id bigint primary key generated always as identity,
content text,
- embedding vector(512)
+ embedding extensions.vector(512)
);
```
@@ -56,7 +56,7 @@ To implement semantic search in Postgres we use `pgvector` - an extension that a
```sql
alter table documents
- add column embedding vector(512);
+ add column embedding extensions.vector(512);
```
In this example, we create a column named `embedding` which uses the newly enabled `vector` data type. The size of the vector (as indicated in parentheses) represents the number of dimensions in the embedding. Here we use 512, but adjust this to match the number of dimensions produced by your embedding model.
@@ -80,7 +80,7 @@ The easiest way to perform semantic search in Postgres is by creating a function
```sql
-- Match documents using cosine distance (<=>)
create or replace function match_documents (
- query_embedding vector(512),
+ query_embedding extensions.vector(512),
match_threshold float,
match_count int
)
@@ -108,7 +108,7 @@ You'll notice we are using the cosine distance (`<=>`) operator in our query. Co
```sql
-- Match documents using negative inner product (<#>)
create or replace function match_documents (
- query_embedding vector(512),
+ query_embedding extensions.vector(512),
match_threshold float,
match_count int
)
@@ -142,7 +142,7 @@ You can also call this method directly from SQL:
```sql
select *
from match_documents(
- '[...]'::vector(512), -- pass the query embedding
+ '[...]'::extensions.vector(512), -- pass the query embedding
0.78, -- chose an appropriate threshold for your data
10 -- choose the number of matches
);
diff --git a/apps/docs/content/guides/ai/structured-unstructured.mdx b/apps/docs/content/guides/ai/structured-unstructured.mdx
index b594ae3c80e..583612f5ccb 100644
--- a/apps/docs/content/guides/ai/structured-unstructured.mdx
+++ b/apps/docs/content/guides/ai/structured-unstructured.mdx
@@ -13,7 +13,7 @@ Most vector stores treat metadata associated with embeddings like NoSQL, unstruc
```sql
create table docs (
id uuid primary key,
- embedding vector(3),
+ embedding extensions.vector(3),
content text,
url text
);
@@ -31,7 +31,7 @@ Notice that we've associated two pieces of metadata, `content` and `url`, with t
```sql
create table docs (
id uuid primary key,
- embedding vector(3),
+ embedding extensions.vector(3),
meta jsonb
);
@@ -84,7 +84,7 @@ The structured metadata style is recommended when the fields being tracked are k
```sql
create table docs (
id uuid primary key,
- embedding vector(3),
+ embedding extensions.vector(3),
content text,
url string,
meta jsonb
diff --git a/apps/docs/content/guides/ai/vector-columns.mdx b/apps/docs/content/guides/ai/vector-columns.mdx
index 9767dfcc074..86d122c5a21 100644
--- a/apps/docs/content/guides/ai/vector-columns.mdx
+++ b/apps/docs/content/guides/ai/vector-columns.mdx
@@ -55,7 +55,7 @@ create table documents (
id serial primary key,
title text not null,
body text not null,
- embedding vector(384)
+ embedding extensions.vector(384)
);
```
@@ -113,7 +113,7 @@ Supabase client libraries like `supabase-js` connect to your Postgres instance v
```sql
create or replace function match_documents (
- query_embedding vector(384),
+ query_embedding extensions.vector(384),
match_threshold float,
match_count int
)
diff --git a/apps/docs/content/guides/database/extensions/http.mdx b/apps/docs/content/guides/database/extensions/http.mdx
index 2daf11fe010..31f5aa4438a 100644
--- a/apps/docs/content/guides/database/extensions/http.mdx
+++ b/apps/docs/content/guides/database/extensions/http.mdx
@@ -94,7 +94,7 @@ A successful call to a web URL from the `http` extension returns a record with t
select
"status", "content"::jsonb
from
- http_get('https://jsonplaceholder.typicode.com/todos/1');
+ extensions.http_get('https://jsonplaceholder.typicode.com/todos/1');
```
### Simple `POST` example
@@ -103,7 +103,7 @@ from
select
"status", "content"::jsonb
from
- http_post(
+ extensions.http_post(
'https://jsonplaceholder.typicode.com/posts',
'{ "title": "foo", "body": "bar", "userId": 1 }',
'application/json'
diff --git a/apps/docs/content/guides/database/extensions/pgrouting.mdx b/apps/docs/content/guides/database/extensions/pgrouting.mdx
index 82ca28f4126..70f7197c8f6 100644
--- a/apps/docs/content/guides/database/extensions/pgrouting.mdx
+++ b/apps/docs/content/guides/database/extensions/pgrouting.mdx
@@ -67,7 +67,7 @@ create table wi29 (
id bigint,
x float,
y float,
- geom geometry
+ geom gis.geometry
);
insert into wi29 (id, x, y)
diff --git a/apps/docs/content/guides/database/extensions/pgvector.mdx b/apps/docs/content/guides/database/extensions/pgvector.mdx
index 56918c381cc..97ead48a31a 100644
--- a/apps/docs/content/guides/database/extensions/pgvector.mdx
+++ b/apps/docs/content/guides/database/extensions/pgvector.mdx
@@ -70,7 +70,7 @@ create table posts (
id serial primary key,
title text not null,
body text not null,
- embedding vector(384)
+ embedding extensions.vector(384)
);
```
diff --git a/apps/docs/content/guides/database/extensions/postgis.mdx b/apps/docs/content/guides/database/extensions/postgis.mdx
index aaf3d18e675..599f65be591 100644
--- a/apps/docs/content/guides/database/extensions/postgis.mdx
+++ b/apps/docs/content/guides/database/extensions/postgis.mdx
@@ -35,11 +35,8 @@ You can get started with PostGIS by enabling the PostGIS extension in your Supab
<TabPanel id="sql" label="SQL">
```sql
--- Create a dedicated separate schema
-create schema if not exists "gis";
-
-- Example: enable the "postgis" extension
-create extension postgis with schema "gis";
+create extension postgis with schema "extensions";
-- Example: disable the "postgis" extension
drop extension if exists postgis;
@@ -58,7 +55,7 @@ Let’s create our table. Each row represents a restaurant with its location sto
create table if not exists public.restaurants (
id int generated by default as identity primary key,
name text not null,
- location gis.geography(POINT) not null
+ location extensions.geography(POINT) not null
);
```
@@ -102,9 +99,9 @@ You can insert geographical data through SQL or through our API.
insert into public.restaurants
(name, location)
values
- ('Supa Burger', gis.st_point(-73.946823, 40.807416)),
- ('Supa Pizza', gis.st_point(-73.94581, 40.807475)),
- ('Supa Taco', gis.st_point(-73.945826, 40.80629));
+ ('Supa Burger', extensions.st_point(-73.946823, 40.807416)),
+ ('Supa Pizza', extensions.st_point(-73.94581, 40.807475)),
+ ('Supa Taco', extensions.st_point(-73.945826, 40.80629));
```
</TabPanel>
@@ -216,18 +213,12 @@ returns table (id public.restaurants.id%TYPE, name public.restaurants.name%TYPE,
set search_path = ''
language sql
as $$
- select id, name, gis.st_y(location::gis.geometry) as lat, gis.st_x(location::gis.geometry) as long, gis.st_distance(location, gis.st_point(long, lat)::gis.geography) as dist_meters
+ select id, name, extensions.st_y(location::extensions.geometry) as lat, extensions.st_x(location::extensions.geometry) as long, extensions.st_distance(location, extensions.st_point(long, lat)::extensions.geography) as dist_meters
from public.restaurants
- order by location operator(gis.<->) gis.st_point(long, lat)::gis.geography;
+ order by location operator(extensions.<->) extensions.st_point(long, lat)::extensions.geography;
$$;
```
-Before being able to call this function from our client we need to grant access to our `gis` schema:
-
-```sql
-grant usage on schema gis to anon, authenticated;
-```
-
Now you can call this function from your client using `rpc()` like this:
<Tabs
@@ -347,9 +338,9 @@ returns table (id public.restaurants.id%TYPE, name public.restaurants.name%TYPE,
set search_path to ''
language sql
as $$
- select id, name, gis.st_y(location::gis.geometry) as lat, gis.st_x(location::gis.geometry) as long
+ select id, name, extensions.st_y(location::extensions.geometry) as lat, extensions.st_x(location::extensions.geometry) as long
from public.restaurants
- where location operator(gis.&&) gis.ST_SetSRID(gis.ST_MakeBox2D(gis.ST_Point(min_long, min_lat), gis.ST_Point(max_long, max_lat)), 4326)
+ where location operator(extensions.&&) extensions.ST_SetSRID(extensions.ST_MakeBox2D(extensions.ST_Point(min_long, min_lat), extensions.ST_Point(max_long, max_lat)), 4326)
$$;
```
diff --git a/apps/docs/content/guides/functions/examples/semantic-search.mdx b/apps/docs/content/guides/functions/examples/semantic-search.mdx
index e05f9be8940..db717653b6c 100644
--- a/apps/docs/content/guides/functions/examples/semantic-search.mdx
+++ b/apps/docs/content/guides/functions/examples/semantic-search.mdx
@@ -28,7 +28,7 @@ create extension if not exists vector with schema extensions;
create table embeddings (
id bigint primary key generated always as identity,
content text not null,
- embedding vector (384)
+ embedding extensions.vector (384)
);
alter table embeddings enable row level security;
@@ -72,7 +72,7 @@ Given the [following Postgres Function](https://github.com/supabase/supabase/blo
--
-- Returns a setof embeddings so that we can use PostgREST resource embeddings (joins with other tables)
-- Additional filtering like limits can be chained to this function call
-create or replace function query_embeddings(embedding vector(384), match_threshold float)
+create or replace function query_embeddings(embedding extensions.vector(384), match_threshold float)
returns setof embeddings
language plpgsql
as $$
diff --git a/apps/docs/content/guides/local-development/testing/pgtap-extended.mdx b/apps/docs/content/guides/local-development/testing/pgtap-extended.mdx
index eba08ccc577..017b29eede9 100644
--- a/apps/docs/content/guides/local-development/testing/pgtap-extended.mdx
+++ b/apps/docs/content/guides/local-development/testing/pgtap-extended.mdx
@@ -26,7 +26,7 @@ select
'PostgreSQL package manager',
resp.contents ->> 'sql'
)
-from http(
+from extensions.http(
(
'GET',
'https://api.database.dev/rest/v1/'
@@ -35,7 +35,7 @@ from http(
|| '&order=version.desc'
|| '&limit=1',
array[
- ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::http_header
+ ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::extensions.http_header
],
null,
null
@@ -141,7 +141,7 @@ select
'PostgreSQL package manager',
resp.contents ->> 'sql'
)
-from http(
+from extensions.http(
(
'GET',
'https://api.database.dev/rest/v1/'
@@ -150,7 +150,7 @@ from http(
|| '&order=version.desc'
|| '&limit=1',
array[
- ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::http_header
+ ('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::extensions.http_header
],
null,
null