Skip to content

Commit dd2363e

Browse files
authored
docs: update docs and some of the scripts that run them (#1560)
1 parent 0572217 commit dd2363e

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@
951951
];
952952
shellHook = ''
953953
export HISTFILE=.history
954+
export DATABASE_URL="postgres://supabase_admin@localhost:5435/postgres?sslmode=disable"
954955
'';
955956
};
956957
cargo-pgrx_0_11_3 = mkCargoPgrxDevShell {

migrations/README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,24 @@ First, start a local postgres server in another terminal window:
8585
nix run .#start-server 15
8686
```
8787

88-
Then, in your main terminal window:
88+
Then, in your main terminal window, run:
8989

9090
```shell
91-
# Set up the database URL for migrations
92-
export DATABASE_URL="postgres://supabase_admin@localhost:5435/postgres?sslmode=disable"
9391

92+
nix develop
93+
```
94+
in the root of `supabase/postgres`.
95+
96+
Next run:
97+
``` shell
9498
# Create a new migration (make sure to specify the migrations directory)
9599
dbmate --migrations-dir="migrations/db/migrations" new '<some message>'
96100
```
97101

98102
Then, execute the migration at `./migrations/db/xxxxxxxxx_<some_message>` and make sure it runs successfully with:
99103

100104
```shell
101-
dbmate up
105+
dbmate --no-dump-schema --migrations-dir"migrations/db/migrations" up
102106
```
103107

104108
Note: Migrations are applied using the `supabase_admin` superuser role, as specified in the "How it was Created" section above.

nix/tools/dbmate-tool.sh.in

+8-1
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,15 @@ perform_dump() {
189189
while [ $attempt -le $max_attempts ]; do
190190
echo "Attempting dbmate dump (attempt $attempt/$max_attempts)"
191191

192+
# Run dbmate dump
192193
if dbmate dump; then
193-
return 0
194+
# Post-process schema.sql to remove schema_migrations INSERT statements
195+
if [ -f "db/schema.sql" ]; then
196+
# Remove INSERT INTO schema_migrations lines
197+
sed -i '/^INSERT INTO schema_migrations/d' db/schema.sql
198+
echo "Schema dump completed successfully (schema_migrations data removed)"
199+
return 0
200+
fi
194201
fi
195202

196203
echo "Dump attempt $attempt failed, waiting before retry..."

0 commit comments

Comments
 (0)