tianon / docker-postgres-upgrade

a PoC for using "pg_upgrade" inside Docker -- learn from it, adapt it for your needs; don't expect it to work as-is!
https://hub.docker.com/r/tianon/postgres-upgrade/
MIT License
1.04k stars 114 forks source link

Upgrade postgresql with postgis extension #33

Closed bellini666 closed 2 years ago

bellini666 commented 3 years ago

I'm trying to upgrade a database that has postgis installed in it. Since the container doing the upgrade doesn't have postgis installed in it it gives this error:

pg_dump: error: query failed: ERROR:  could not access file "$libdir/postgis-3": No such file or directory
SuperSandro2000 commented 3 years ago

Install postgis in the container. You can create a Dockerfile which depends on the right container and built that.

bellini666 commented 3 years ago

Yeah, I ended up doing that! This is the dockerfile I used, with another extension that I use there too.

FROM tianon/postgres-upgrade:12-to-13

RUN apt-get update
RUN apt-get install -y \
  postgresql-12-postgis-3 \
  postgresql-12-postgis-3-scripts \
  postgresql-12-first-last-agg \
  postgresql-13-postgis-3 \
  postgresql-13-postgis-3-scripts \
  postgresql-13-first-last-agg \
  libproj-dev \
  gdal-bin

Maybe it would be nice to have this documented somewhere. Or maybe it is something so obvious that shouldn't need any doc?

tianon commented 3 years ago

I wouldn't say that it's "so obvious", but also this repository isn't actually meant to be an end-all solution. The point is that performing this upgrade automatically requires both instances of PostgreSQL (including any necessary/used extensions) installed simultaneously in order to use the PostgreSQL-native upgrade functionality, which is definitely really complicated. :disappointed:

Given the documentation we have is already pretty complex (and difficult to follow IMO), I'm not sure where we could add this that wouldn't just lead to more confusion instead of less. :grimacing:

theAkito commented 3 years ago

Fully agree with @tianon here. The upgrade process itself is already not very straight-forward. Then add Docker and all its implications on top of it. Additionally, Docker is often used with an Orchestrator. Another level of arduousness on top of that.

Now, when this gets even more features for special cases, it would get even more complicated. It's probably best to keep this project as a basic (haha) upgrade tool, just for upgrading plain Postgres to Postgres. Users with higher demands could make a version of this tool with the features others usually wouldn't need. This way the users have a choice, everyone is happy and the normal user with normal demands does not have to deal with potential issues arising from advanced features.