npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

postgres-fill

v0.0.5

Published

Simple Node.js utility to help maintaining compatibility between Postgres databases.

Readme

postgres-fill

Simple Node.js utility to help maintaining compatibility between Postgres databases.

This little program helps you to maintain the compatibility between Postgres databases by comparing their structure with one specified in a JSON file: if it finds a table, column or constraint (primary key, foreign key, unique and index) that is not described in the JSON file, it gets added to the database.

This program does not perform alterations or deletions - it will only "expand" the databases, in order to avoid conflicts with current versions.

Obs: conflict with 'unique' constraints may occur, if they are specified in the JSON structure but the tables are holding duplicate values.

To install it, use npm:

$ npm install postgres-fill --save-dev

To run it, include the module and pass 4 arguments (the last one is optional):

require('postgres-fill')(log, connectionOptions, structure, verbose);
// log = Function that takes a string as a parameter - you can pass a log stream here
// connectionOptions = described below
// structure = described below
// verbose = defaults to 'false'. 'true' will print very detailed messages, while 'false' will only print messages
//           informing about modifications in the database

connectionOptions

// Describes how to connect to the database
{
  host: string, // Host
  user: string, // Your username
  password: string, // Your password
  database: string, // Name of the database
  port: number // Recommended: 5432
}

Example:

{
  "host": "192.168.0.1",
  "user": "root",
  "password": "password",
  "database": "myDatabase",
  "port": 5432
}

structure

// Describes the structure of the database
[
  { // Represents a table
    name: string, // Name for the table
    description?: string, // Description (optional, not used for queries)
    disabled?: boolean, // If true, the table will be ignored
    columns: [{ // List of columns
      name: string, // Name of the column
      type: string, // Type (use the same name as in Postgres: int, varchar, etc)
      isNull?: boolean, // Is the column nullable?
      disabled?: boolean, // If true, the column will be ignored
      size?: number, // Size of the data type (like varchar(20))
      primaryKey?: boolean, // Is this field a primary key?
      defaultValue?: any // Default value
    }],
    foreignKeys?: [{ // Foreign keys in this table
      column: string, // Name of the local column
      referenceTable: string, // Name of the table to be referenced
      referenceColumn: string, // Name of the column to be referenced (in the referenced table)
      onDelete?: string, // ON DELETE action (setNull, setDefault, restrict, cascade, or noAction)
      onUpdate?: string // ON UPDATE actin (setNull, setDefault, restrict, cascade, or noAction)
    }],
    unique?: [string], // List of unique columns (by name)
    index?: [string] // List of index columns (by name)
  }
]

!!! Note: The 'defaultValue' field will take your input literally, so if your default value is a string, wrap it around single quotes.

Example:

[
  {
    "name": "User",
    "description": "This table has the users",
    "disabled": false,
    "columns": [{
      "name": "id",
      "type": "serial",
      "isNull": false,
      "primaryKey": true
    }, {
      "name": "name",
      "type": "varchar",
      "size": 30,
      "isNull": true
    }, {
      "name": "userType",
      "type": "varchar",
      "size": 30,
      "defaultValue": "'regular'",
    }],
    "unique": ["name"],
    "index": ["id"]
  }, {
    "name": "Company",
    "description": "This table has the companies",
    "disabled": false,
    "columns": [{
      "name": "id",
      "type": "serial",
      "isNull": false,
      "primaryKey": true
    }, {
      "name": "name",
      "type": "varchar",
      "size": 30,
      "isNull": true
    }, {
      "name": "owner",
      "type": "int",
      "isNull": false
    }, {
      "name": "dateCreated",
      "type": "timestamp",
      "defaultValue": "now()",
    }],
    "foreignKeys": [{
      "column": "owner",
      "referenceTable": "User",
      "referenceColumn": "id",
      "onDelete": "restrict",
      "onUpdate": "noAction"
    }],
    "unique": ["name"],
    "index": ["id", "name"]
  }
]