fergusstrange / embedded-postgres

Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test
MIT License
854 stars 89 forks source link

Return an error instead of deleting data on upgrade #83

Closed kylecarbs closed 2 years ago

kylecarbs commented 2 years ago

When upgrading the version of PostgreSQL, all data was deleted. This seems like undesired user behavior because there's not a clear warning message that everything will be reset.

https://github.com/fergusstrange/embedded-postgres/blob/7bf3aab2dca3964165ded64585e2516791c88876/embedded_postgres.go#L112-L118

I think returning an error due to a data version mismatch PostgreSQL won't start is more expected, and causes less risk of users just losing all of their data.

fergusstrange commented 2 years ago

Hi @kylecarbs this tool is really intended for testing and was built from the ground up with that at the heart of the core design.

Initially we needed a "clean" instance of Postgres per test, which is generally good practice when testing so that your tests run in isolation.

For this reason we wouldn't really want to return an error, unless perhaps it was configured to do so.

What is your use case?

ljmatkins commented 2 years ago

I would be interested in using this project to store state for a wails app (https://github.com/wailsapp/wails). @fergusstrange , would you advise against this?

kylecarbs commented 2 years ago

@fergusstrange we're currently using embedded-postgres as a way for easy installations with Coder, which should work in production-like settings for small deployments.

Installing PostgreSQL just to try software is a pain, so we've used this lib to make the process simpler for our users.

fergusstrange commented 2 years ago

@ljmatkins yes this is primarily written for testing.