Skip to content

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

feat: adds version and table drop guides

awalias44ea019a0f51
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index ab1a5a3cbce..bd86249c517 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -615,32 +615,8 @@ export const resources = {
name: 'Postgres resources',
url: undefined,
items: [
- { name: 'Basics', url: '/guides/resources/postgres' },
- { name: 'Managing Postgres Databases', url: '/' },
- { name: 'RLS Policies', url: '/' },
- { name: '...', url: '/' },
- {
- name: 'Child 1',
- url: '/guides/resources/postgres/child1',
- items: [
- {
- name: 'grandchild1',
- url: '/guides/resources/postgres/child1/grandchild1',
- items: [],
- },
- ],
- },
- {
- name: 'Child 2',
- url: '/guides/resources/postgres/child2',
- items: [
- {
- name: 'grandchild2',
- url: '/guides/resources/postgres/child2/grandchild2',
- items: [],
- },
- ],
- },
+ { name: 'Drop all tables in schema', url: '/guides/resources/postgres/dropping-all-tables-in-schema' },
+ { name: 'Print PostgreSQL version', url: '/guides/resources/postgres/which-version-of-postgres' },
],
},
],
diff --git a/apps/docs/pages/guides/resources/postgres/child1/grandchild1.mdx b/apps/docs/pages/guides/resources/postgres/child1/grandchild1.mdx
deleted file mode 100644
index fa81fc8c23a..00000000000
--- a/apps/docs/pages/guides/resources/postgres/child1/grandchild1.mdx
+++ /dev/null
@@ -1,12 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- title: 'Grandchild1',
- description: 'creating a table.........',
-}
-
-Grandchild 1....
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/docs/pages/guides/resources/postgres/child1/index.mdx b/apps/docs/pages/guides/resources/postgres/child1/index.mdx
deleted file mode 100644
index 291eebbfd91..00000000000
--- a/apps/docs/pages/guides/resources/postgres/child1/index.mdx
+++ /dev/null
@@ -1,13 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- title: 'Child 1',
- description:
- 'Resources to help you get up to speed with Postgres, the database powering Supabase.',
-}
-
-Child 1
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/docs/pages/guides/resources/postgres/child2/grandchild2.mdx b/apps/docs/pages/guides/resources/postgres/child2/grandchild2.mdx
deleted file mode 100644
index 8234c354286..00000000000
--- a/apps/docs/pages/guides/resources/postgres/child2/grandchild2.mdx
+++ /dev/null
@@ -1,13 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- title: 'Grandchild2',
- description:
- 'Resources to help you get up to speed with Postgres, the database powering Supabase.',
-}
-
-Grandchild 2
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/docs/pages/guides/resources/postgres/child2/index.mdx b/apps/docs/pages/guides/resources/postgres/child2/index.mdx
deleted file mode 100644
index cafdace4f7d..00000000000
--- a/apps/docs/pages/guides/resources/postgres/child2/index.mdx
+++ /dev/null
@@ -1,13 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- title: 'Child2',
- description:
- 'Resources to help you get up to speed with Postgres, the database powering Supabase.',
-}
-
-Child2.....
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/docs/pages/guides/resources/postgres/dropping-all-tables-in-schema.mdx b/apps/docs/pages/guides/resources/postgres/dropping-all-tables-in-schema.mdx
new file mode 100644
index 00000000000..2db4653beba
--- /dev/null
+++ b/apps/docs/pages/guides/resources/postgres/dropping-all-tables-in-schema.mdx
@@ -0,0 +1,35 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ title: 'Drop all tables in a PostgreSQL schema',
+ description:
+ 'Useful snippet for deleting all tables in a given schema',
+}
+
+If you need to drop all tables in a given schema, you can execute the query below.
+
+Make sure to replace `my-schema-name` with the name of your schema. In Supabase, the default schema is `public`.
+
+<Admonition type="warning">
+
+This will delete all tables and their associated data. Ensure you have recent [backups](/docs/guides/platform/backups) before proceeding.
+
+</Admonition>
+
+```sql
+do $$ declare
+ r record;
+begin
+ for r in (select tablename from pg_tables where schemaname = 'my-schema-name') loop
+ execute 'drop table if exists ' || quote_ident(r.tablename) || ' cascade';
+ end loop;
+end $$;
+```
+
+This snippet works by first listing out all the tables in the given schema. And then executing a `drop table` for each, hence the `for... loop`.
+
+You can run this query from the [SQL editor](https://app.supabase.com/project/_/sql) inside the Supabase dashboard, or via psql if [connecting directly via the command line](/docs/guides/database/connecting-to-postgres#direct-connections).
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/apps/docs/pages/guides/resources/postgres/which-version-of-postgres.mdx b/apps/docs/pages/guides/resources/postgres/which-version-of-postgres.mdx
new file mode 100644
index 00000000000..2c2bd5826a8
--- /dev/null
+++ b/apps/docs/pages/guides/resources/postgres/which-version-of-postgres.mdx
@@ -0,0 +1,27 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ title: 'Print PostgreSQL version',
+ description:
+ 'Useful snippet for finding out which version of postgres you are running',
+}
+
+It's important to know which version of PostgreSQL you are running, since each major version has different features and may cause breaking changes. If [upgrading](https://www.postgresql.org/docs/current/pgupgrade.html) or downgrading a major Postgres version, you may need to update your schema.
+
+From the [SQL editor](https://app.supabase.com/project/_/sql) you can run the simple query:
+
+```sql
+select version();
+```
+
+Which should return something like:
+
+```sql
+PostgreSQL 15.1 on aarch64-unknown-linux-gnu, compiled by gcc (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0, 64-bit
+```
+
+This query can also be executed via psql or any other query editor if you prefer to [connect directly to the database](/docs/guides/database/connecting-to-postgres#direct-connections).
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page