Constructive provides GraphQL server and code generation tools, while PGPM handles database migrations and packages. Install both for the complete workflow.
npm install -g @constructive-io/cli pgpmGenerate a workspace along with its default services configuration:
pgpm init workspace # then enter workspace name
cd myworkspaceThe workspace includes a docker-compose.yml you can use to start Postgres and supporting services:
docker-compose up -dIf you already have Postgres installed locally, just ensure it is running and accessible.
pgpm init
cd packages/mymodule
# Add schema
pgpm add --change schemas/myschema
# Add table (depends on schema)
pgpm add --change schemas/myschema/tables/mytable --requires schemas/myschemadeploy/schemas/myschema.sql
-- Deploy: schemas/myschema to pg
-- made with <3 @ constructive.io
CREATE SCHEMA myschema;deploy/schemas/myschema/tables/mytable.sql
-- Deploy: schemas/myschema/tables/mytable to pg
-- made with <3 @ constructive.io
-- requires: schemas/myschema
CREATE TABLE myschema.mytable (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);pgpm deploy --database testdb --createdb --yesSample output highlights:
- Creates database
testdb - Installs declared extensions (
citext,pgcrypto) - Initializes migration schema
- Deploys schema + table successfully
[deploy] SUCCESS: Starting deployment to database testdb...
[migrate] SUCCESS: Successfully deployed: schemas/myschema
[migrate] SUCCESS: Successfully deployed: schemas/myschema/tables/mytable
[deploy] SUCCESS: Deployment complete for mymodule.
cnc explorerhttp://localhost:5555/graphiql (default) http://myschema.testdb.localhost:5555/graphiql (specific to a schema)
cnc server