Git Product home page Git Product logo

Comments (12)

sebastienvermeille avatar sebastienvermeille commented on July 20, 2024 6

I think the following solution would looks quite sexy:

  • a dependency for postgres-embedded (without extensions) <- what we have actually
  • add the possibility to detect other dependencies: another dependency which contains postgis-postgres-embedded-extension <-- and if it is present via reflection we copy some parts of it into the postgres embedded somehow ?

If we could reach such things that would be very flexible and allow anybody to create new extensions for pg-embedded without impacting it :)

@stevenschlansker I would be happy to contribute on this feature part if you want. (at least provide you some help if I can)

from otj-pg-embedded.

mnd999 avatar mnd999 commented on July 20, 2024 2

plv8 would be useful as well

from otj-pg-embedded.

stevenschlansker avatar stevenschlansker commented on July 20, 2024 2

We could add the ability to unpack another tarball on top of the base postgres installation, and then the extension initialization can run through the current DatabasePreparer interface. Would that be sufficient? Or you can provide a whole postgres with custom libraries.

from otj-pg-embedded.

srstsavage avatar srstsavage commented on July 20, 2024 1

Any dev thoughts on @tatut's suggestion or any other method to add extensions to pg-embedded? Such a solution would make pg-embedded much more useful.

from otj-pg-embedded.

stevenschlansker avatar stevenschlansker commented on July 20, 2024

That's something we would like to support. I haven't tried postgis personally since before I started this project but any help on figuring out what needs to be done would be much appreciated!

from otj-pg-embedded.

tatut avatar tatut commented on July 20, 2024

My understanding is that extensions are simply shared object files in the library directory.

I took a look around my project's docker db (pg 9.5 + postgis 2.2) and postgis extension is at:

/usr/lib/postgresql/9.5/lib/postgis_topology-2.2.so
/usr/lib/postgresql/9.5/lib/postgis-2.2.so
/usr/lib/postgresql/9.5/lib/rtpostgis-2.2.so

Also support files seem to be under /usr/share/postgresql/9.5/extension/ which has a bunch of postgis--<version>.sql files which are loaded when the extension is created and a postgis.control which has the following content:

# postgis extension
comment = 'PostGIS geometry, geography, and raster spatial types and functions'
default_version = '2.2.1'
module_pathname = '$libdir/postgis-2.2'
relocatable = true

Other extensions seem to follow the same pattern: a .control and .sql files in the extension folder and a shared object in to lib directory.

Perhaps pg-embedded could simply provide an extension hook that calls some code with the libdir and extension dir as parameters prior to starting the embedded server binary? That should make it possible to bring your own extensions.

from otj-pg-embedded.

tatut avatar tatut commented on July 20, 2024

Something along the lines of:

class Extender implements PgExtender {
    public void beforeStart(String system, String machineHardware, File libraryDir, File extensionDir) throws IOException {
        /* Code to copy system/hardware specific  shared objects to library directory
            and common .control and .sql files to extension directory */
    }
}

EmbeddedPostgreSQL
            .builder()
            .setPgExtender(new Extender())
            .start();

from otj-pg-embedded.

KevinvdBosch avatar KevinvdBosch commented on July 20, 2024

@stevenschlansker We've created the postgis extension for windows distribution: https://github.com/IDgis/otj-pg-embedded to be used locally. There is no gradle/maven dependency yet.
Maybe something to add as a default, because it's very useful for us and a much better way than to have h2 mock a postgres database with postgis extension.

from otj-pg-embedded.

LuboVarga avatar LuboVarga commented on July 20, 2024

Just side info. Another handy extension is also timescaledb. Also starlingbank have forked this project with one interesting commit. Given commit adds pgtap extension.

from otj-pg-embedded.

mabdelsamie avatar mabdelsamie commented on July 20, 2024

Is this also related to pg_trgm extension? I'm trying to run CREATE EXTENSION IF NOT EXISTS pg_trgm before starting my unit tests but it fails.

from otj-pg-embedded.

Panic7 avatar Panic7 commented on July 20, 2024

So is PostGIS supported now? Or can someone suggest a valid solution for use in tests?

from otj-pg-embedded.

gmkohler avatar gmkohler commented on July 20, 2024

@Panic7 I had success moving to https://github.com/testcontainers/testcontainers-java which are more finnicky to set up in CI but ultimately more extensible

from otj-pg-embedded.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.