0.0.62 • Published 10 years ago

artisan-pg v0.0.62

Weekly downloads
27
License
-
Repository
github
Last release
10 years ago

#artisan-pg a lighweight wrapper for node-pg.

this is a work in progress, do not attempt to use in a production env

###works out of the box with the following structure

+ROOT_DIR
    +node_modules
    +db
        -config.json
        +seeds
            -index.js
        +migrations
            -index.js

the location of these files can be changed in /lib/config.js

###currently supports 5 functions

bake create

creates a db with the name specified in db/config.json

bake drop

drops a db with the name specified in db/config.json

bake seed

runs db/seeds/index.js#seed

bake migration [filename]

creates a migration file in db/migrations with the syntax [filename]_YYYYMMDDHHMMSS.js containing the code:

exports.up = function() {

}

exports.down = function() {

}

bake migrate versionNumber - optional

runs a migration from the version specified in `db/schema.js` (defaults to 0 if no file)
runs up or down to the specified version number (runs all the way up if none specified)
saves version number in `db/schema.js`
WARNING: Running this overwrites any content in `db/schema.js` or your specified schemaFile


##examples
###example `db/config.json` file

{ "global": { "username": "bendyorke" , "password": "artisan-pg" , "database": "postgres" , "hostname": "localhost" } , "development": { "username": "bendyorke" , "password": "artisan-pg" , "database": "progress_dev" , "hostname": "localhost" }
}

###example `db/seeds/index.js` file

exports.seed = function() { var fs = require('fs') , path = require('path')

fs .readdirSync(dirname) .filter(function(file) { return ( (file.indexOf('.') !== 0) && (file !== 'index.js') && (file.slice(-3) === '.js') ) }) .forEach(function(file) { require(path.join(dirname, file))() }) }

0.0.62

10 years ago

0.0.61

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago