Skip to content

devlanes is in beta and not ready for production use.Report an issue

Run installs, migrations and seeds

A command that runs and ends, such as an install, a migration or a seed, is a task: devlanes runs it at the lane event you choose, or when you name it.

::example{slug="infra-postgres-shared"}

devlanes.yaml
tasks:
install:
run: [npm, install]
when: lane.create
migrate:
run_script:
file: package.json
name: db:migrate
when: lane.start
seed:
run_script:
file: package.json
name: db:seed
when: lane.create
after: services

The install runs on a new lane’s first start, until it succeeds once, and again after you change its entry. The migration runs each time the lane comes up, before its services, so the migration tool has to skip what it already applied. The seed runs once the services are ready, for work that goes through the running app. Start order and readiness has the whole order.

A task without an event runs only when you name it, and any task can be run that way:

~/dev/myapp
$ devlanes run migrate

Give it a question, which the run asks before it starts; scripts and agents pass --yes instead:

devlanes.yaml
tasks:
reset-db:
steps: [infra.teardown.database, infra.setup.database, migrate, seed]
confirm: Drop the database of ${{ lane.name }} and seed it again?

The steps run in order, here the entries that drop and create the lane’s database from Share one database server between lanes, then two tasks.

Tasks on lane.stop run when you stop the whole lane or the daemon, and tasks on lane.clean when you clean the lane. A logout or a shutdown of the machine skips stop tasks, so a dump that has to happen goes in a task you run yourself.