4 ms·
> about their test environment having the ability to automatically fork the database for every new test run, such that they could easily "revert" (in their case
by petepete 3y ago
> about their test environment having the ability to automatically fork the database for every new test run, such that they could easily "revert" (in their case ignore/walk away from) the database after a test run
I think this should be really straightforward by using one database as a template for another. This is how Postgres's create database works and it defaults to Template1
https://www.postgresql.org/docs/current/manage-ag-templatedbs.html https://www.postgresql.org/docs/current/manage-ag-templatedb...
- jasfi 3y agoThe intention of pg_branch is to optimize this process. They mention two problems: 1. The template database can't have active connections during the CREATE DATABASE process. 2. The CREATE DATABASE from a template database can be slow for large DBs.
- ilyt 3y ago> The template database can't have active connections during the CREATE DATABASE process. Why would that be a problem ?
- dalore 3y agoIf you are trying to branch prod (or even a staging db) then you can't
- ComputerGuru 3y agoRight. But the obvious solution is to just not do that. Create a template and base production/staging off it, then use that template. Or use the same bootstrap/migration process to create the template as you do staging. Regular tests shouldn’t assume access to staging/prod, anyway.
- conceptme 3y agoSo how do you test your migration? Will work fine with 10 records but perhaps not with 10 million.
- ComputerGuru 3y agoI don’t consider that “a regular test” but something db-specific that would have a custom workflow.
- workingjubilee 3y agoEliminating "custom workflows" seems like rather the point of such an extension.
- rokkitmensch 3y agoRun it in a transaction, and if it fails, abort the transaction. nbd, did this for years in prod. Discovered some interesting assumptions about sequential IDs in the DB tests while running it against prod under peak load, too!
- dalore 3y agoIf you have lots of data, this can take some time The appeal of this project is that it uses CoW (copy on write), so in theory it should be fast to copy as it only maintains writes.