Skip to content

Repository files navigation

migraine -- Simple Postgres schema management

 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.

Features

  • SQL schema migrations
  • set passwords for Postgres roles
  • usable both as a command-line tool and a library

Ideals

  • simple
  • easily understandable
  • robust

Anti-goals

  • databases other than Postgres, simpler code is better
  • command to create a new file for a migration
  • "down" migrations

About

Simple Postgres schema management

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages