npm.io
0.1.6 • Published 7 years ago

guff

Licence
MIT
Version
0.1.6
Deps
4
Size
201 kB
Vulns
0
Weekly
0

guff

A no-nonsense extension of Knex migrations for use with PostgreSQL clients.


Guff extends the functionality of Knex with special column types and extra utilities for building out your schemas (e.g. triggers and functions).

Requirements

const guff = require('guff')

const TABLE = 'accounts'
exports.TABLE = TABLE

exports.up = function (knex, Promise) {
  return guff.createTable(
    knex,
    TABLE, [
      guff.col('uid').primary(),
      guff.col('email').unique().notNullable(),
      guff.col('password', 'text').notNullable(),
      guff.col('key'),
      guff.col('oauth_providers', 'jsonb'),
      guff.col('join_ip', 'ip').notNullable(),
      guff.col('last_ip', 'ip').notNullable(),
      guff.col('activated', 'boolean').defaultTo(false).notNullable(),
      guff.col('created_at'),
      guff.col('updated_at')
    ]
  )
}

exports.down = function (knex) {
  return guff.dropTable(knex, TABLE)
}