Skip to content

Commit 9f6c64e

Browse files
authored
Merge pull request #130 from supabase/docs/move-installer-docs
move database.dev/installer page content into docs
2 parents 30e62bf + 52c5a24 commit 9f6c64e

File tree

7 files changed

+93
-84
lines changed

7 files changed

+93
-84
lines changed

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ dbdev is a package manager for Postgres [trusted language extensions](https://gi
2424
- dbdev CLI: a CLI for publishing TLEs to a registry.
2525
- dbdev client: an in-database client for installing TLEs from registries.
2626

27-
If you want to publish your own TLE, you will need the dbdev CLI. Follow its [installation instructions](install.md) to get started.
27+
If you want to publish your own TLE, you will need the dbdev CLI. Follow its [installation instructions](install-cli.md) to get started.
2828

2929
If you want to install an extension from the registry, you will need the SQL dbdev client. Follow its [installation instructions](https://database.dev/installer) to enable it in your database.

docs/install.md renamed to docs/install-cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ Alternatively, you can build the binary from source. You will need to have [Rust
5252

5353
If you have [cargo-install](https://doc.rust-lang.org/cargo/commands/cargo-install.html), you can perform all the above steps with a single command: `cargo install --git https://github.com/supabase/dbdev.git dbdev`.
5454

55-
Now you're ready to [publish your first package](publish.md).
55+
Now you're ready to [publish your first package](publish-extension.md).

docs/install-in-db-client.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
You can install extensions available on the database.dev registry using the dbdev in-database client. The dbdev client is itself an extension which you can install by following the instructions below.
2+
3+
## Installation
4+
5+
Before you can install the dbdev extension into your database, ensure you have the following dependencies already installed:
6+
7+
- [pg_tle](https://github.com/aws/pg_tle)
8+
- [pgsql-http](https://github.com/pramsey/pgsql-http)
9+
10+
!!! note
11+
12+
If you database is running on Supabase, the above dependencies are already installed.
13+
14+
Run the following SQL to install the client:
15+
16+
```sql
17+
create extension if not exists http with schema extensions;
18+
create extension if not exists pg_tle;
19+
select pgtle.uninstall_extension_if_exists('supabase-dbdev');
20+
drop extension if exists "supabase-dbdev";
21+
select
22+
pgtle.install_extension(
23+
'supabase-dbdev',
24+
resp.contents ->> 'version',
25+
'PostgreSQL package manager',
26+
resp.contents ->> 'sql'
27+
)
28+
from http(
29+
(
30+
'GET',
31+
'https://api.database.dev/rest/v1/'
32+
|| 'package_versions?select=sql,version'
33+
|| '&package_name=eq.supabase-dbdev'
34+
|| '&order=version.desc'
35+
|| '&limit=1',
36+
array[
37+
('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::http_header
38+
],
39+
null,
40+
null
41+
)
42+
) x,
43+
lateral (
44+
select
45+
((row_to_json(x) -> 'content') #>> '{}')::json -> 0
46+
) resp(contents);
47+
create extension "supabase-dbdev";
48+
select dbdev.install('supabase-dbdev');
49+
drop extension if exists "supabase-dbdev";
50+
create extension "supabase-dbdev";
51+
```
52+
53+
## Use
54+
55+
Once the client is installed, you an install a TLE available on database.dev by running SQL that looks like the following:
56+
57+
```sql
58+
select dbdev.install(<extension_name>);
59+
create extension <extension_name>
60+
schema <schema>
61+
version <version>;
62+
```
63+
64+
For example, to install pg_headerkit version 1.0.0 in schema public run:
65+
66+
```sql
67+
select dbdev.install('burggraf-pg_headerkit');
68+
create extension "burggraf-pg_headerkit"
69+
schema 'public'
70+
version '1.0.0';
71+
```

docs/publish.md renamed to docs/publish-extension.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mkdir my_first_tle
2323
cd my_first_tle
2424
```
2525

26-
Next create a `hello_world--0.0.1.sql` file, which will contain your extension's SQL objects. Add the following function definition to this file:
26+
Next create a `hello_world--0.0.1.sql` file, which will contain your extension's SQL objects. Add the following function definition to this file:
2727

2828
```sql
2929
create function greet(name text default 'world')
@@ -52,4 +52,4 @@ Now run the `dbdev publish` command to publish it.
5252
dbdev publish
5353
```
5454

55-
Your extension is now published to `database.dev` and visible under your account profile. You can visit your account profile from the account drop-down at the top right. Users can now install your extension using the [dbdev in-database client](https://database.dev/installer).
55+
Your extension is now published to `database.dev` and visible under your account profile. You can visit your account profile from the account drop-down at the top right. Users can now install your extension using the [dbdev in-database client](install-in-db-client.md).

mkdocs.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ repo_url: https://github.com/supabase/dbdev
77

88
nav:
99
- Welcome: 'index.md'
10-
- Install CLI: 'install.md'
11-
- Publish a Package: 'publish.md'
10+
- Install CLI: 'install-cli.md'
11+
- Publish a Package: 'publish-extension.md'
12+
- Install a Package: 'install-in-db-client.md'
1213
- Structure of a Postgres Extension: 'extension_structure.md'
1314

1415
theme:
@@ -18,6 +19,7 @@ theme:
1819
homepage: https://supabase.github.io/dbdev
1920
features:
2021
- navigation.expand
22+
- content.code.copy
2123
palette:
2224
primary: black
2325
accent: light green

website/pages/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ const IndexPage: NextPageWithLayout = () => {
9090
<p className="dark:text-white">
9191
Install the dbdev client in your PostgreSQL database by following
9292
the guide{' '}
93-
<Link href="/installer" className="border-b">
93+
<Link
94+
href="https://supabase.github.io/dbdev/install-in-db-client/"
95+
className="border-b"
96+
>
9497
here
9598
</Link>
9699
. Publish your own trusted language extension by following{' '}

website/pages/installer.tsx

+10-77
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,20 @@
11
import Head from 'next/head'
2+
import { useRouter } from 'next/router'
23
import Layout from '~/components/layouts/Layout'
34
import Markdown from '~/components/ui/Markdown'
45
import { NextPageWithLayout } from '~/lib/types'
56

67
const InstallerPage: NextPageWithLayout = () => {
7-
return (
8-
<>
9-
<Head>
10-
<title>Installer | The Database Package Manager</title>
11-
</Head>
12-
13-
<div className="mb-16">
14-
<Markdown>
15-
{`# Install dbdev
16-
17-
To install the dbdev extension into your database, ensure you have the following dependencies installed and then run the following SQL:
18-
19-
Requires:
20-
- pg_tle: https://github.com/aws/pg_tle
21-
- pgsql-http: https://github.com/pramsey/pgsql-http
22-
23-
*If your database is running on [Supabase](https://supabase.com), these dependencies are already installed.*
24-
25-
\`\`\`sql
26-
create extension if not exists http with schema extensions;
27-
create extension if not exists pg_tle;
28-
select pgtle.uninstall_extension_if_exists('supabase-dbdev');
29-
drop extension if exists "supabase-dbdev";
30-
select
31-
pgtle.install_extension(
32-
'supabase-dbdev',
33-
resp.contents ->> 'version',
34-
'PostgreSQL package manager',
35-
resp.contents ->> 'sql'
36-
)
37-
from http(
38-
(
39-
'GET',
40-
'https://api.database.dev/rest/v1/'
41-
|| 'package_versions?select=sql,version'
42-
|| '&package_name=eq.supabase-dbdev'
43-
|| '&order=version.desc'
44-
|| '&limit=1',
45-
array[
46-
('apiKey', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhtdXB0cHBsZnZpaWZyYndtbXR2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODAxMDczNzIsImV4cCI6MTk5NTY4MzM3Mn0.z2CN0mvO2No8wSi46Gw59DFGCTJrzM0AQKsu_5k134s')::http_header
47-
],
48-
null,
49-
null
50-
)
51-
) x,
52-
lateral (
53-
select
54-
((row_to_json(x) -> 'content') #>> '{}')::json -> 0
55-
) resp(contents);
56-
create extension "supabase-dbdev";
57-
select dbdev.install('supabase-dbdev');
58-
drop extension if exists "supabase-dbdev";
59-
create extension "supabase-dbdev";
60-
\`\`\`
61-
62-
## Use
63-
64-
Once the client is installed, you an install a TLE available on [database.dev](https://database.dev/) by running SQL that looks like the following:
65-
66-
\`\`\`sql
67-
select dbdev.install(<extension_name>);
68-
create extension <extension_name>
69-
schema <schema>
70-
version <version>;
71-
\`\`\`
72-
73-
For example, to install [pg_headerkit](https://database.dev/burggraf/pg_headerkit) version \`1.0.0\` in schema \`public\` run:
8+
return null
9+
}
7410

75-
\`\`\`sql
76-
select dbdev.install('burggraf-pg_headerkit');
77-
create extension "burggraf-pg_headerkit"
78-
schema 'public'
79-
version '1.0.0';
80-
\`\`\``}
81-
</Markdown>
82-
</div>
83-
</>
84-
)
11+
export async function getServerSideProps() {
12+
return {
13+
redirect: {
14+
destination: '/supabase/dbdev',
15+
permanent: true,
16+
},
17+
}
8518
}
8619

8720
InstallerPage.getLayout = (page) => <Layout>{page}</Layout>

0 commit comments

Comments
 (0)