Used to update the database schema (tables, types, views)
Create a migration at db/migrations/
. You’ll then need to go update the file per your migration. See existing migrations for examples
deno task db:migrate create my_new_migration
Migrate to latest.
# Running db:migrate:local * task runs a db:migrate:* against both vha_dev and vha_test
deno task switch:local
deno task db:migrate local latest
# Migrating production from your local machine
# Heroku will migrate to latest automatically on deploy
deno task switch:prod
deno task db:migrate latest
If this works, export the database’s types to db.d.ts by
deno task db:codegen
If this works, you’re done! If you notice any issues you can migrate down like so
deno task db:migrate:down
While we have no live users, it’s often easier to wipe the DB and then apply your migrations from scratch. Reach out to the team in #engineering as you’re doing this
Wipe the DB while on the main
branch. This (should) clear all tables, types, views, etc. If it doesn’t, it means our down()
functions need to be updated
deno task db:migrate local reset
Switch to your feature branch with the new migrations.
git checkout feature-branch
Migrate to latest.
deno task db:migrate:latest
deno task db:local seed load $target # loads a partilar seed, from tsv if available or from the definition otherwise
deno task db:local seed dump $target # dumps the contents of database tables to .tsv files
deno task db:local seed drop $target # truncate the corresponding tables from the database
deno task db:local seed recreate $target # reloads the seed from its definition and dumps .tsv files
deno task db:local reset