stripe / pg-schema-diff

Go library for diffing Postgres schemas and generating SQL migrations
MIT License
364 stars 26 forks source link

[Question] Why not use `pg_dump --schema-only` to populate temporary database? #170

Open aleclarson opened 2 months ago

aleclarson commented 2 months ago

I've been facing some frustrating issues with the temporary database. Specifically, composite types aren't copied into it, leading to failed setup within assertValidPlan.

Instead of generating migration statements to setup the temporary database, we should dump every schema returned by fetchNamedSchemas and run those dump files on the temporary database.

aleclarson commented 2 months ago

I'm going to add a --temp-db flag that pg-schema-diff will use instead of creating its own. This will allow me to workaround this issue in the meantime. Let me know if you'd like me to open a PR with that flag.

Navbryce commented 2 months ago

I strongly recommend skipping plan validation (it's a flag). pg-schema-diff inherently relies on being to diff(empty db, your source db schema). So if your source db contains any schema objects that aren't supported, it will break

Navbryce commented 2 months ago

It doesn't use pg_dump because many hosts don't have pg_dump or support for libpq. I'd be open to adding support it for hosts that have it installed.