xataio / pgroll

PostgreSQL zero-downtime migrations made easy
https://www.xata.io
Apache License 2.0
2.97k stars 54 forks source link

Questions about setup with zero downtime usage #371

Closed dolezvo1 closed 1 month ago

dolezvo1 commented 1 month ago

Hi, I'm sorry, this is not an issue with the program as such, but I'm just not completely clear on the recommended usage and the implications from reading the documentation. What I'm not clear about is mainly this: in the readme you say to set the search path for new clients like this:

SET search_path TO 'public_initial_migration';

Does that mean that the new clients will be able to use this search path without issues any issues after the migration is complete, i.e. that the temporary schema is not deleted? If so, are there any safeguards in case of a rollback? My first thought was actually to do something like the following, but I think that is not actually safe in case of a rollback, so I wanted to check if there is a better way to do this:

SET search_path TO public_initial_migration, public;
dolezvo1 commented 1 month ago

Oh, I see, it seems that the new schema is not being deleted, so that seems promising? I assume that means that in case of a rollback, new clients simply have a search_path with one non-existent schema, and therefore can't cause any harm?

exekias commented 1 month ago

pgroll ensures that there is at least one schema version active at all times. We only delete the old version schema after you complete a new migration. Ideally the workflow would be as this:

dolezvo1 commented 1 month ago

Thanks!