Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-validator

postgresql database schema validation and creation utility

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

pg-validator

Simple PostgreSQL database schema validation and creation.

#Overview

An alternative to using sql files to ensure a specific schema

Takes a yaml file as input and does a drop validate create in that order, depending on command line flags.

#Installation

TODO: NPM

#Usage

Usage: pg_validate [options]

Options:

-h, --help                      output usage information
-V, --version                   output the version number
-f, --file [file name]          schema definition file
-h, --host [host name]          postgresql host name or ip
-u, --user [user name]          postgresql user name
-p, --password [user password]  postgresql password
-z, --validate                  validate schema
-d,  --drop                     drop schema tables
-c, --create                    create schema

#Configuration files

Configuration files should be made one per database, consider the simple.yaml example:

---
#####
#An example db specification
#####
db_name : testdb
tables :
  neighbors :
    columns :
      id : increments
      name : string
      address :
        type : string
        unique : true
      spouse_name : 
        type : string
        defaultTo : No Spouse
    primary : id
    unique : name

  associates :
    columns :
      id : increments
      name : string
      address :
        type : string
        unique : true
      company_name : text
    primary : id
    unique : [name, company_name]

While relatively straightforward, pg-validator is a simple wrapper around the Knex module. Database columns are either simple a string, denoting the type, or an object.

Columns that are defined as objects are required to have a type. Other parameters must follow the Knex schema definition functions for columns. In case the knex function does not have any parameters, the boolean value true should be used. This is demonstrated in the example above with the column spouse_name.

All table properties other than the reserved keyword columns map to table commands. An array denotes multiple calls, while nested arrays will translate to an array being passed to the knex which is chained.

For example, to define multiple unique columns: unique : [col1, col2, col3]

Compounded: unique : [[col1, col2]]

Can mix and match, each element of the array maps to one chained knex.table call unique : [col1, [col2, col3]]

#License

MIT

Keywords

FAQs

Package last updated on 10 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc