Socket
Socket
Sign inDemoInstall

node-mini-migrations

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-mini-migrations

A very small, lightweight and flexible migrations library unconcerned with what database you use


Version published
Weekly downloads
47
increased by11.9%
Maintainers
1
Weekly downloads
 
Created
Source

Mini Migrations for NodeJS

Build Status David DM GitHub code size in bytes GitHub package.json version GitHub

A really simple node migrations library that is completely independant of any database or file system.

Installation

npm install --save node-mini-migrations

Example Usage

There are two examples, one using sqlite and another using a pretend custom file system database.

SQLite Driver Filesystem Driver

const sqlite = require('sqlite')

module.exports = function () {
  let db

  return {
    init: async () => {
      db = await sqlite.open('./test.sqlite')
      await db.run('CREATE TABLE IF NOT EXISTS _migrations (file TEXT PRIMARY KEY);')
    },

    finish: async () => {
      await db.close()
    },

    getMigrationState: async (id) => {
      return db.get('SELECT file FROM _migrations WHERE file = ?', [id])
    },

    setMigrationUp: async (id) => {
      return db.run('INSERT INTO _migrations (file) VALUES (?)', [id])
    },

    setMigrationDown: async (id) => {
      return db.run('DELETE FROM _migrations WHERE file = ?', [id])
    },

    getPassedFunctions: async () => {
      return db
    }
  }
}

Usage

You run migrator up to bring up any migrations or migrator down to bring them down.

Or inside node app
const {up, prepareRun} = require('node-mini-migrations')
up(prepareRun('./migrations'))

License

This project is licensed under the terms of the GPLv3 license.

FAQs

Package last updated on 07 Nov 2019

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