8000 docs: update docs and some of the scripts that run them by samrose · Pull Request #1560 · supabase/postgres · GitHub
[go: up one dir, main page]

Skip to content

docs: update docs and some of the scripts that run them #1560

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

Merged
merged 1 commit into from
Apr 21, 2025
Merged
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
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@
];
shellHook = ''
export HISTFILE=.history
export DATABASE_URL="postgres://supabase_admin@localhost:5435/postgres?sslmode=disable"
'';
};
cargo-pgrx_0_11_3 = mkCargoPgrxDevShell {
Expand Down
12 changes: 8 additions & 4 deletions migrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,24 @@ First, start a local postgres server in another terminal window:
nix run .#start-server 15
```

Then, in your main terminal window:
Then, in your main terminal window, run:

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

nix develop
```
in the root of `supabase/postgres`.

Next run:
``` shell
# Create a new migration (make sure to specify the migrations directory)
dbmate --migrations-dir="migrations/db/migrations" new '<some message>'
```

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

```shell
dbmate up
dbmate --no-dump-schema --migrations-dir"migrations/db/migrations" up
```

Note: Migrations are applied using the `supabase_admin` superuser role, as specified in the "How it was Created" section above.
Expand Down
9 changes: 8 additions & 1 deletion nix/tools/dbmate-tool.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,15 @@ perform_dump() {
while [ $attempt -le $max_attempts ]; do
echo "Attempting dbmate dump (attempt $attempt/$max_attempts)"

# Run dbmate dump
if dbmate dump; then
return 0
# Post-process schema.sql to remove schema_migrations INSERT statements
if [ -f "db/schema.sql" ]; then
# Remove INSERT INTO schema_migrations lines
sed -i '/^INSERT INTO schema_migrations/d' db/schema.sql
echo "Schema dump completed successfully (schema_migrations data removed)"
return 0
fi
fi

echo "Dump attempt $attempt failed, waiting before retry..."
Expand Down
0