All Projects → fullcube → loopback-component-migrate

fullcube / loopback-component-migrate

Licence: other
Migration framework for loopback

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to loopback-component-migrate

loopback-ds-paginate-mixin
A mixin to provide pagination for loopback Model properties
Stars: ✭ 31 (-27.91%)
Mutual labels:  mit, loopback, lb2, fullcube
loopback-component-mq
Loopback Component for working with a Message Queue
Stars: ✭ 19 (-55.81%)
Mutual labels:  mit, loopback, lb2, loopback-component
Loopback Component Access Groups
Access controls for Loopback.
Stars: ✭ 56 (+30.23%)
Mutual labels:  mit, loopback
Colmena
Colmena is a starter kit for an API with an Admin interface that can be easily extended and built upon.
Stars: ✭ 1,420 (+3202.33%)
Mutual labels:  mit, loopback
trona
Write DB migrations with SQL and run them with a CLI
Stars: ✭ 31 (-27.91%)
Mutual labels:  migration
sprockets-bumble d
Sprockets plugin to transpile modern javascript using Babel, useful while migrating to ES6 modules
Stars: ✭ 32 (-25.58%)
Mutual labels:  migration
go-echo-boilerplate
The fastest way to build a restful API with golang and echo framework. Includes common required features for modern web applications. A boilerplate project with golang and Echo.
Stars: ✭ 53 (+23.26%)
Mutual labels:  migration
MIT6.824-2021
4 labs + 2 challenges + 4 docs
Stars: ✭ 594 (+1281.4%)
Mutual labels:  mit
documentation
Pterodactyl's documentation is open source! This repository contains the documentation for installing and updating both the panel and the daemon.
Stars: ✭ 99 (+130.23%)
Mutual labels:  mit
loopback-connector-mongodb
The official MongoDB connector for the LoopBack framework.
Stars: ✭ 183 (+325.58%)
Mutual labels:  loopback
mgmigrate
mgmigrate is a tool for migrating data from MySQL or PostgreSQL to Memgraph and between Memgraph instances.
Stars: ✭ 17 (-60.47%)
Mutual labels:  migration
magento-ngrok
Magento 2 module for ngrok.io service support
Stars: ✭ 45 (+4.65%)
Mutual labels:  mit
loopback-connector-firestore
Firebase Firestore connector for the LoopBack framework.
Stars: ✭ 32 (-25.58%)
Mutual labels:  loopback
schema-builder
Laravel/Lumen schema builder & migration generator
Stars: ✭ 51 (+18.6%)
Mutual labels:  migration
fire-starter
Starter kit for the fireloop.io platform
Stars: ✭ 16 (-62.79%)
Mutual labels:  loopback
loopback-typescript-example
Loopback with TypeScript
Stars: ✭ 13 (-69.77%)
Mutual labels:  loopback
maildir2gmail
Maildir 2 Gmail
Stars: ✭ 14 (-67.44%)
Mutual labels:  migration
fastfreeze
Turn-key solution to checkpoint/restore applications running in Linux containers
Stars: ✭ 68 (+58.14%)
Mutual labels:  migration
bullshit-detector
🔍 Chráňte vašich blízkych pred nedôveryhodným 🇸🇰 a 🇨🇿 obsahom
Stars: ✭ 24 (-44.19%)
Mutual labels:  mit
Squeaky-Android
Appropriately lightweight database creations and migrations with SQLite on Android
Stars: ✭ 34 (-20.93%)
Mutual labels:  migration

A library to add simple database migration support to loopback projects.

Dependencies

Migrations that have been run will be stored in a table called 'Migrations'. The library will read the loopback datasources.json files based on the NODE_ENV environment variable just like loopback does. The usage is based on the node-db-migrate project.

Installation

Greenkeeper badge

  1. Install in you loopback project:

npm install --save loopback-component-migrate

  1. Create a component-config.json file in your server folder (if you don't already have one)

  2. Enable the component inside component-config.json.

{
  "loopback-component-migrate": {
    "key": "value"
  }
}

Options:

  • log

    [String] : Name of the logging class to use for log messages. (default: 'console')

  • enableRest

    [Boolean] : A boolean indicating wether migrate/rollback REST api methods should be exposed on the Migration model. (default: false)

  • migrationsDir

    [String] : Directory containing migration scripts. (default: server/migrations)

  • dataSource

    [String] : Datasource to connect the Migration and MigrationMap models to. (default: db)

  • acls

    [Array] : ACLs to apply to Migration and MigrationMap models. (default: [])

Running Migrations

Migrations can be run by calling the static migrate method on the Migration model. If you do not specify a callback, a promise will be returned.

Run all pending migrations:

Migrate.migrate('up', function(err) {});

Run all pending migrations upto and including 0002-somechanges:

Migrate.migrate('up', '0002-somechanges', function(err) {});

Rollback all migrations:

Migrate.migrate('down', function(err) {});

Rollback migrations upto and including 0002-somechanges:

Migrate.migrate('down', '0002-somechanges', function(err) {});

Example migrations

module.exports = {
  up: function(app, next) {
    app.models.Users.create({ ... }, next);
  },
  down: function(app, next) {
    app.models.Users.destroyAll({ ... }, next);
  }
};
/* executing raw sql */
module.exports = {
  up: function(app, next) {
    app.dataSources.mysql.connector.query('CREATE TABLE `my_table` ...;', next);
  },
  down: function(app, next) {
   app.dataSources.mysql.connector.query('DROP TABLE `my_table`;', next);
  }
};
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].