2.0.1 • Published 6 months ago

pg-schema-dump v2.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

Node PG Schema Dump pg-schema-dump

!WARNING If you're upgrading from version 1, it's likely there are many breaking changes. In Version 2 we switched off libpq-query so that we could have node-native query parsing/generation.

This is an alternative to pg_dump written in node. You can use this to get all the SQL to recreate a schema or a diretory representing a schema, which is awesome for viewing database changes.

npm.io

Installation

npm add -D pg-schema-dump

Usage

schema.sql dumping

# By default, pg-dump knows POSTGRES_HOST, DATABASE_URL, etc.
pg-schema-dump dump

# Dump schema.sql to stdout for public schema on default database "postgres"
pg-schema-dump dump -h localhost -U postgres

# With postgres URL
pg-schema-dump dump psql://user:1234@localhost:5432/my_db

Tree Dumping

"Tree Dumps" are great for code reviews. They use a directory structure to easily diff database changes. For example, a table definition goes into a file in <schema>/<table>/table.sql. This makes it easy to find and examine different parts of your database in a structured way.

pg-schema-dump dump-tree /path/to/dir

# You can use the same environment variables or specify the host etc.
pg-schema-dump dump-tree -h localhost -U postgres /path/to/dir

As a Library

import { getSchemaSQL, getTree } from "pg-schema-dump"

// Uses environment variables, DATABASE_URL etc.
await getSchemaSQL({
  schemas: ["public"],
})

await getTree({
  schemas: ["public"],
})
2.0.1

6 months ago

2.0.0

6 months ago

1.0.6

8 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago