0.2.4 • Published 29 days ago

migoose v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
29 days ago

tests

Migoose

After working many years with mongoose, I faced a problem, I needed to run migrations in an app which was bundled with @vercel/ncc for running in a Docker container in Kubernetes.

Problem was, all solutions I could find involved globbying a migrations directory for files at runtime.

I needed something which generated code referenced by my codebase through imports to be included in that bundle.

Hence, it is born migoose, it implements a command-line utility which will generate the migration files for you, and a utility which will run them.

Installing

You can run npm install migoose or yarn add migoose in the command line.

Note that you will run it in production, so it must not be a dev dependency.

Usage

yarn migoose create

This will prompt for a migration description, and then it will generate the file for you. Once it has been generated you can just edit it with whatever your heart desires.

Configuration

You can configure migoose by creating a .migooserc file in the root of your project.

{
  "dir": "migrations",
  "typescript": false,
  "es6": false
}

You don't need to specify a database connection since it will use mongoose's connection.

Running Migrations

Please note that for simplicity there is no "down" migration, so if you need to revert a migration you will need add another one undoing stuff.

import mongoose from 'mongoose';
import { Migoose } from 'migoose';

await import('./migrations')
await Migoose.migrate(mongoose) // It needs your Mongoose instance.
0.2.4

29 days ago

0.2.3

11 months ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago