Skip to content

Commit 38c11a4

Browse files
committed
draft
1 parent 75b0643 commit 38c11a4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/install/database.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,33 @@ Using the `search_path` in the connection string corresponds to the following `p
7070
ALTER ROLE coder SET search_path = myschema;
7171
```
7272

73+
## Migrating from the built-in database
74+
75+
If you installed Coder on a VM and would like to migrate your built-in database, you can dump the database and restore on the external database.
76+
77+
```sh
78+
# Get the built in Postgres URL for the "coder" user
79+
export CODER_BUILT_IN_DB_URL=$(sudo -u coder /bin/bash -c 'coder server postgres-builtin-url --raw-url')
80+
81+
# Dump the "coder" database to coder.sql (PostgreSQL client required)
82+
pg_dump $CODER_BUILT_IN_DB_URL --no-publications --no-owner > coder.sql
83+
```
84+
85+
To
86+
87+
```sh
88+
export CODER_EXTERNAL_DB_URL=postgres://coder:secret42@localhost/coder?sslmode=disable
89+
pg_restore -d $CODER_EXTERNAL_DB_URL coder.sql
90+
91+
psql $CODER_EXTERNAL_DB_URL -f coder.sql
92+
93+
SELECT 'ALTER TABLE public.' || table_name || ' SET SCHEMA myschema;' FROM information_schema.tables WHERE table_schema = 'public' AND table_type = 'BASE TABLE';
94+
95+
96+
97+
psq
98+
```
99+
73100
## Troubleshooting
74101

75102
### Coder server fails startup with "current_schema: converting NULL to string is unsupported"

0 commit comments

Comments
 (0)