Skip to content

Commit 5df96ad

Browse files
Add migration script instructions
1 parent f795591 commit 5df96ad

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

charts/supabase/README.md

+42
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,48 @@ The secret can be created with kubectl via command-line:
128128

129129
> If you depend on database providers like [StackGres](https://stackgres.io/) or [Postgres Operator](https://github.com/zalando/postgres-operator) you only need to remove the `secret.db` values and direcly creating a new `<helm-deploy-name>-supabase-db` secret.
130130

131+
#### Migration scripts
132+
133+
Supabase migration scripts can be specified at `db.config` field. This will apply all of the migration scripts during the database initialization. For example:
134+
135+
```yaml
136+
db:
137+
config:
138+
20230101000000_profiles.sql: |
139+
create table profiles (
140+
id uuid references auth.users not null,
141+
updated_at timestamp with time zone,
142+
username text unique,
143+
avatar_url text,
144+
website text,
145+
146+
primary key (id),
147+
unique(username),
148+
constraint username_length check (char_length(username) >= 3)
149+
);
150+
```
151+
152+
To make copying scripts easier, use this handy bash script:
153+
154+
```bash
155+
#!/bin/bash
156+
157+
clipboard="\n"
158+
for file in $1/*; do
159+
clipboard+=" $(basename $file): |\n"
160+
clipboard+=$(cat $file | awk '{print " "$0}')
161+
done
162+
163+
echo -e "$clipboard"
164+
```
165+
166+
and pipe it to your system clipboard handler:
167+
168+
```shell
169+
# Using xclip as an example
170+
./script.sh supabase/migrations | xclip -sel clipboard
171+
```
172+
131173
### Dashboard secret
132174

133175
By default, a username and password is required to access the Supabase Studio dashboard. Simply change them at:

0 commit comments

Comments
 (0)