Databases
Starting data
A copied environment's databases start empty. A Postgres database can start with a copy of its source instead, the source's latest backup, or a seed file from the branch.
Two rules hold everywhere:
- Data flows down, schema flows up. Data goes from a database into its
copy, never back. Schema reaches
prodthrough a merge and a deploy. - A copy never writes to its source. The source is only read.
The options
| Starts with | What happens | Cost |
|---|---|---|
| Empty (default) | Your migrations create the tables | None |
| Data from the source now | The source is dumped and restored into the copy | Read load on the source |
| Latest backup | The newest backup is restored | None; up to a day old |
| Seed file | phz/seed.sql from the branch runs once | None; you maintain it |
A seed file
phz/seed.sql, read from the copy's branch at the commit it was made from,
up to 10 MB. The migrations in phz/migrations/ run first, then the first
deploy of every service that uses the database, then the seed, in one
transaction. It runs once.