WaspW
Wasp2y ago
Estelle

Add extension postgis

I want to add the PostGIS extension to my db.

I added this into my main.wasp :
  db: {
    system: PostgreSQL,
    prisma: {
      clientPreviewFeatures: ["postgresqlExtensions"],
      dbExtensions: [
        { name: "postgis", version: "3" },
      ]
    },
  },


Problem:
db error: ERROR: extension "postgis" has no installation script nor update path for version "3"


So I added the installation script:
docker ps
docker exec -it [container_id] bash
apt update
apt install postgis postgresql-16-postgis-3


I succeeded to add the extension manually in the local database with:
CREATE EXTENSION IF NOT EXISTS postgis;


Problem:
Error: P3006

Migration `20240611131009_add_postgis_extension` failed to apply cleanly to the shadow database. 
Error:
db error: ERROR: extension "postgis" has no installation script nor update path for version "3"
   0: schema_core::state::DevDiagnostic
             at schema-engine/core/src/state.rs:266



:x: --- [Error] Migrate dev failed: ------------------------------------------------

Migrate (dev) failed with exit code: 1

The shadow database doesn't have the script I added to the local database.



So I tried something else :
I buit my docker image with postgres16 + the script that I want to use locally so the database and the shadow database will have the script.
I add to my env :
DATABASE_URL=postgresql://postgres:mysecretpassword@localhost:5432/postgres

But impossible to use my built database as "local" :
The database needs to be running in order to execute this command. You can easily start a managed dev database with `wasp start db`.



How can I add my extension please?
Was this page helpful?