schwifty-migration

0.0.3 • Public • Published

schwifty-migration

An Objection.js model migration tool for use during development

Build Status Coverage Status Security Status

Getting Started

  • Run npm install
  • Install the right version of 'schwifty'
npm install git+https://github.com/BigRoomStudios/schwifty.git#add-schwifty-migration
  • Install 'schwifty-migration'
npm install git+https://github.com/BigRoomStudios/schwifty-migration.git

  • Create an npm 'migrate' script so that schwifty's migrationsMode plugin option is set to either 'create' or 'alter'.

Ex.

// package.json
"scripts": {
    "migrate": "MIGRATE=alter npm start"
}
  • Now Go to where schwifty gets registered on your server (server/manifest.js for example), and add the migrationsMode plugin option.

Ex.

$base: {
    migrateOnStart: true,
+   migrationsMode: process.env.MIGRATE,
    knex: {
        client: 'sqlite3',
        useNullAsDefault: true,
        connection: {
            filename: ':memory:'
        }
    }
}
  • If all goes well, the process will stop and the generated migration file location will be printed to the console. It'll look like this:
//////////////////////////
/////// Success! /////////
Generated new migration file:

/Users/$(whoami)/path/to/migrations/20170817143549_schwifty-migration.js
  • Pro-tip: Triple click the line with the filepath, copy, then run atom + paste in terminal to edit the file in Atom.

Package Sidebar

Install

npm i schwifty-migration

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

322 kB

Total Files

57

Last publish

Collaborators

  • williamswoodruff