|
1 | 1 | import Head from 'next/head' |
| 2 | +import { useRouter } from 'next/router' |
2 | 3 | import Layout from '~/components/layouts/Layout' |
3 | 4 | import Markdown from '~/components/ui/Markdown' |
4 | 5 | import { NextPageWithLayout } from '~/lib/types' |
5 | 6 |
|
6 | 7 | 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 | +} |
74 | 10 |
|
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 | + } |
85 | 18 | } |
86 | 19 |
|
87 | 20 | InstallerPage.getLayout = (page) => <Layout>{page}</Layout> |
|
0 commit comments