Skip to content

Commit

Permalink
Merge pull request #1540 from visualize-admin/docs/vercel-dev-db
Browse files Browse the repository at this point in the history
docs: Add bit on migrations & dev database
  • Loading branch information
ptbrowne authored May 29, 2024
2 parents 051b459 + fd86f2f commit 072a53d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ yarn dev:rollup
#### Database migrations

Database migrations are run automatically when the _production_ app starts. In _development_, you'll have to run them manually:
Database migrations are run automatically when a production build of the app starts. In _development_, you'll have to run them manually:

```sh
yarn db:migrate:dev
Expand All @@ -100,6 +100,18 @@ Migrations are located in `db-migrations/`. Write SQL or JS migrations and follo

For detailed instructions, please refer to the [postgres-migrations](https://github.com/thomwright/postgres-migrations) documentation.

⚠️ On Vercel environments like "preview" and "production", "production" build are started which means that database migrations are executed.
Since all environments are sharing the same database, it means that a database migration executing on 1 database could be disruptive to
other preview deployments. For example adding a column to the schema would be disruptive, since other preview deployments would try to
remove it (since the column is not yet in the schema). To prevent any problems on preview deployments, we have a second database that
is special for development and that must be used if you are working on a branch that brings in database changes. You can configure
this in the Vercel environment variables by copy-pasting the environment variables found in the [visualization-tool-postgres-dev][]
storage (see `.env.local` tab), and copy paste them as [environment variables](https://vercel.com/ixt/visualization-tool/settings/environment-variables)
in the visualisation-project. Take care of scoping the new environment variables to the preview branch you are working on.
After merging the branch, you can delete the environment variables scoped to the branch.

[visualization-tool-postgres-dev](https://vercel.com/ixt/visualization-tool/stores/postgres/store_dV3rog1asOXO3BfC/data)

## Versioning

New versions of `package.json` are built on GitLab CI into a separate image that will be deployed to the integration env.
Expand Down

0 comments on commit 072a53d

Please sign in to comment.