schemamap/postgres

By schemamap

Updated over 1 year ago

The official postgres image extended with the Schemamap.io SDK.

Image
Networking
Developer tools
Databases & storage
2

551

schemamap/postgres repository overview

Postgres with Schemamap.io SDK

The official postgres image enhanced with the Schemamap.io SDK (schemamap schema).

Dockerfile source

Getting Started

Simply replace your existing docker-compose.yml image reference:

services:
  postgres:
    image: postgres
    ...

with:

services:
  postgres:
    image: schemamap/postgres
    ...

Or via docker run:

docker run --name schemamap-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 schemamap/postgres

This allows to immediately use and configure the Schemamap.io SDK for your application schema via psql.

Sample usage

$ psql -h 127.0.0.1 -p 5432 -U postgres
grant usage on schema public to schemamap;

-- get a list of User-Defined Functions (UDFs) that can be configured:
select schemamap.update_function_definition();

-- get the current definition of the given UDF
select schemamap.update_function_definition('ignored_schemas');

-- override UDF
select schemamap.update_function_definition('ignored_schemas', $$
  values ('pg_catalog'), ('information_schema'), ('schemamap')
$$);

grant select on organizations to schemamap;

--  Teaching schemamap how your tenants are defined in the given database
select schemamap.update_function_definition('list_tenants', $$
  select
    id as tenant_id,
    slug as tenant_short_name,
    name as tenant_display_name,
    'en_US' as tenant_locale,
    jsonb_build_object('logo', logo) as tenant_data
  from organizations;
$$);

grant select on products to schemamap;

-- Defining groupings of tables to form a higher-level logical data-model
-- to be copied/imported via Schemamap.io
select schemamap.define_master_data_entity('products', $$
  select * 
  from products p
  join product_settings on ps.product_id = p.id; 
$$);

-- Refreshing the columnar denormalized view that Schemamap.io uses to introspect your schema
select schemamap.update_schema_metadata_overview();

-- Which you can query, allowing for simple SQL querying of your schema, without need for a GUI
select * from schemamap.schema_metadata_overview;

To see all available functions, run:

\df schemamap.*

TCP port forwarding

To enable local-first development and receiving anonymized data from your other Postgres instances via Schemamap.io, the image includes the rathole binary.

After receiving a personal, project-specific TCP tunnel configuration from https://app.schemamap.io/, you can easily connect to the platform via:

docker exec -i schemamap-postgres port-fwd-postgres < rathole-client.toml

Tag summary

Content type

Image

Digest

sha256:7fde7f184

Size

152 MB

Last updated

over 1 year ago

docker pull schemamap/postgres:17.0-v0.4.2