Skip to content

Commit

Permalink
docs: add guide for removing foreign data wrappers (#390)
Browse files Browse the repository at this point in the history
* docs: add guide for removing foreign data wrappers

- Add comprehensive guide for removing FDWs
- Cover both native and WASM wrapper cleanup
- Include verification steps
- Fixes #177

Co-Authored-By: [email protected] <[email protected]>

* docs: update SQL queries to use lowercase and pg_catalog

- Convert all SQL queries to lowercase
- Replace information_schema with pg_catalog
- Add full table qualification
- Improve query readability with column aliases

Co-Authored-By: [email protected] <[email protected]>

* docs: update SQL queries and remove WASM cleanup steps

Co-Authored-By: [email protected] <[email protected]>

* docs: update SQL queries with aliases and remove verification section

Co-Authored-By: [email protected] <[email protected]>

* Update docs/guides/removing-wrappers.md

* Update docs/guides/removing-wrappers.md

* Update docs/guides/removing-wrappers.md

* Update docs/guides/removing-wrappers.md

* docs: add removing wrappers guide to nav list

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Oliver Rice <[email protected]>
Co-authored-by: Bo Lu <[email protected]>
  • Loading branch information
4 people authored Dec 17, 2024
1 parent 054a42d commit ef78590
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
64 changes: 64 additions & 0 deletions docs/guides/removing-wrappers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Removing Foreign Data Wrappers

This guide explains how to fully remove all foreign data wrappers from your PostgreSQL database.


## Components to Remove

When removing a foreign data wrapper, you need to remove several components in the correct order:

1. Foreign Tables
2. Foreign Servers
3. Wrappers Extension

## Step-by-Step Removal Process

### 1. List and Remove Foreign Tables

First, list all foreign tables associated with your wrapper:

```sql
select c.relname as foreign_table_name,
n.nspname as schema_name
from pg_catalog.pg_foreign_table ft
join pg_catalog.pg_class c on c.oid = ft.ftrelid
join pg_catalog.pg_namespace n on n.oid = c.relnamespace;
```

Remove each foreign table:

```sql
drop foreign table if exists schema_name.table_name;
```

### 2. Remove Foreign Servers

List servers:

```sql
select fs.srvname as server_name,
fdw.fdwname as wrapper_name
from pg_catalog.pg_foreign_server fs
join pg_catalog.pg_foreign_data_wrapper fdw on fdw.oid = fs.srvfdw;
```

Remove each server:

```sql
drop server if exists server_name cascade;
```

!!! note

With `cascade` option, this will also drop all foreign tables using that foreign server.

### 3. Remove the Extension

```sql
drop extension if exists wrappers cascade;
```

!!! note

With `cascade` option, this will also drop all foreign servers and foreign tables using Wrappers extension.

1 change: 1 addition & 0 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ nav:
- Security: 'guides/security.md'
- FDW Statistics: 'guides/usage-statistics.md'
- Installing Wrappers in Postgres: 'guides/installation.md'
- Removing Foreign Data Wrappers: 'guides/removing-wrappers.md'
- Limitations: 'guides/limitations.md'
- Developing a Wasm Wrapper:
- Quick Start: 'guides/create-wasm-wrapper.md'
Expand Down

0 comments on commit ef78590

Please sign in to comment.