export DATABASE_URL='postgresql://postgres:pgdev@localhost/pgdev'
deno run \
--allow-env=DATABASE_URL,PGHOST,PGPORT,PGUSER,PGPASSWORD,PGDATABASE,PGAPPNAME,PGOPTIONS \
--allow-net=localhost:5432 \
--allow-read=/migrations,/secrets/pgformyapp \
jsr:@tv42/migraine \
--migrations=/migrations \
--auth=myapp=/secrets/pgformyapp
(Unfortunately, deno-postgres accesses the PGHOST etc environment variables even when explicitly configured: denodrivers/postgres#418.)
export PGHOST=localhost
export PGPORT=5432
export PGUSER=postgres
export PGPASSWORD=pgdev
export PGDATABASE=postgres
deno run \
--allow-env=DATABASE_URL,PGHOST,PGPORT,PGUSER,PGPASSWORD,PGDATABASE,PGAPPNAME,PGOPTIONS \
--allow-net=localhost:5432 \
--allow-read=/migrations,/secrets/pgformyapp \
jsr:@tv42/migraine \
--migrations=/migrations \
--auth=myapp=/secrets/pgformyapp
Put migrations in a separate directory, with names like 001_description_here.sql.
Put Postgres role passwords each in a separate file.
- SQL schema migrations
- set passwords for Postgres roles
- usable both as a command-line tool and a library
- simple
- easily understandable
- robust
- databases other than Postgres, simpler code is better
- command to create a new file for a migration
- "down" migrations