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

knex-migrator

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knex-migrator

Database migrations with knex.

  • 0.0.3
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
increased by8.14%
Maintainers
1
Weekly downloads
 
Created
Source

knex-migrator

DB migration tool for knex

install

npm install -g knex-migrator --save

important facts

If you are using mysql, knex-migrator is able to create the database for you. If it already exists, it skips. Don't forget to set your connection.charset.

config

knex-migrator requires a config file. Please provide a file named .knex-migrator in your project root.

#!/usr/bin/env node

module.exports = {
    database: {
        client: 'mysql',
        connection: {
            host: '127.0.0.1',
            user: 'user',
            password: 'password',
            charset: 'utf8',
            name: 'ghost'
        }
    },
    migrationPath: process.cwd() + '/core/server/data/migrations'
}
#!/usr/bin/env node

module.exports = {
    database: {
        client: 'sqlite3',
        connection: {
            filename: 'path/to/your.db'
        }
    },
    migrationPath: process.cwd() + '/core/server/data/migrations'
}

CLI usage

knex-migrator help
knex-migrator init
knex-migrator init --skip 1
knex-migrator init --only 1

JS usage

var KnexMigrator = require('knex-migrator');
var knexMigrator = new KnexMigrator({
    knexMigratorFilePath: 'path-to-migrator-config-file' [optional]
});

// check your database health
knexMigrator.isDatabaseOK()
  .then(function() {
     // database is OK
  })
  .catch(function(err) {
     // database is not initialised?
     knexMigrator.init();
  });

your migration folder (example)

  • init
    • 1-create-tables
    • 2-seed

Keywords

FAQs

Package last updated on 17 Oct 2016

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