Skip to content
Merged
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
22 changes: 15 additions & 7 deletions migrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,31 @@ Additionally, [supabase/postgres](https://github.com/supabase/postgres/blob/deve

### Add a Migration

First, start a local postgres server and apply the migrations
First, start a local postgres server in another terminal window:

```shell
# Start the database server
nix run .#dbmate-tool -- --version 15 --flake-url "."
# Start the database server in another window
nix run .#start-server 15
```

# create a new migration
nix develop
dbmate new '<some message>'
Then, in your main terminal window:

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

# 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 `./db/migrations/xxxxxxxxx_<some_message>` and make sure it runs sucessfully with
Then, execute the migration at `./migrations/db/xxxxxxxxx_<some_message>` and make sure it runs successfully with:

```shell
dbmate up
```

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

### Adding a migration with docker-compose

dbmate can optionally be run locally using docker:
Expand Down
Loading