developmentseed / eoAPI

[Active Development] Earth Observation API (Metadata, Raster and Vector services)
https://eoapi.dev
MIT License
197 stars 21 forks source link

Register postgis extension on user DB using superuser role, to avoid permissions issues. #20

Closed edkeeble closed 2 years ago

edkeeble commented 2 years ago

What's the issue?

I ran into this issue when adapting this code for use with csdap-orders and spinning up a new DB. The pypgstac migrations attempt to register postgis in the pgstac DB, if it isn't already present. Since the migrations are run as as non-superuser, registering the extension fails.

How am I fixing it?

This isn't a perfect fix, since pypgstac could always be updated in the future to attempt to register other extensions, but for now I'm just registering the postgis extension on the pgstac DB using the superuser credentials. This allows the migrations to run with the non-superuser, as they won't attempt to register the extension if it already exists.