Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add section for removing Zero leftovers #35

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions contents/docs/cleanup/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: Cleanup
---

## Removing Zero from your project

You may want to remove Zero from your project for a variety of reasons - regardless, there are a few things you can do to completely remove Zero from your project.

### Schemas

Zero makes all its data changes to your database in its own postgres "schemas".


To list all schemas when using `psql`, you can use the following command:

```bash
psql -c "\dN"
```

There are two schemas used

`zero`

This schema is for tracking zero-related data unrelated to a replica (shared amongst all replicas). Currently there is just one table - the schema version used for migration.

`zero_0`

This schema is used for tracking zero-related data that is per-replica. In the screenshot, I have just one replica but there can be more, zero_1, zero_2, etc when you have zero running multi-node in production.

First, double check for all Zero associated schemas:


```bash
psql -c "/dt zero.*"
```

```bash
psql -c "/dt zero_0.*"
```

Which should show something like this:

<ImageLightbox src="/images/cleanup/drop-schema-1.png" alt="Example of console window showing Zero associated schemas" />

and also:

<ImageLightbox src="/images/cleanup/drop-schema-2.png" alt="Example of console window showing Zero associated schemas" />


You can then drop these individually with the `DROP SCHEMA` command.

As an example, to drop the `zero` schema, you can use the following command:

```bash
psql -c "DROP SCHEMA zero CASCADE;"
```

<Note type="warning">
**Note:** We reccomend you do these individually to avoid any mistakes.
</Note>

### Event Triggers

Zero also installs some event triggers related to schema management. These postgres features are global and can't be associated w/ schemas. To find them:

```bash
psql -c "SELECT * FROM pg_event_trigger;"
```
<ImageLightbox src="/images/cleanup/pg-triggers.png" alt="" />

You can drop each of these with the `DROP EVENT TRIGGER` command.

For example:

```bash
psql -c "DROP EVENT TRIGGER zero_dd1_start_0 ON pg_event_trigger;"
```

You would need repeat this command for each trigger associated with Zero
1 change: 1 addition & 0 deletions lib/routes-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const ROUTES: EachRoute[] = [
{title: 'Deployment', href: '/deployment'},
{title: '`zero-cache` Config', href: '/zero-cache-config'},
{title: 'Recipes', href: '/recipes'},
{title: 'Cleanup', href: '/cleanup'},
],
},

Expand Down
Binary file added public/images/cleanup/drop-schema-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/cleanup/drop-schema-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/cleanup/pg-triggers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.