Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run from CLI #9

Closed
retani opened this issue Jul 12, 2020 · 5 comments
Closed

Run from CLI #9

retani opened this issue Jul 12, 2020 · 5 comments

Comments

@retani
Copy link

retani commented Jul 12, 2020

How can I run this from CLI – and how would I set the MONGO URL?

@qqilihq
Copy link
Member

qqilihq commented Jul 13, 2020

Write a wrapper script as seen in the readme. Call this from CLI.

@qqilihq qqilihq closed this as completed Jul 13, 2020
@retani
Copy link
Author

retani commented Jul 14, 2020

Thanks for the quick reply and the contributing this package.

Here is an example wrapper for using the migrate cli command with state storage in your mongo db:

// migrate.js

var migrate = require('migrate')
const { MongoStateStore } = require('@nodepit/migrate-state-store-mongodb');

const MONGODB_URI = "mongodb://localhost:27017"

module.exports = class MyMongoStateStore extends MongoStateStore {
  constructor() {
    super(MONGODB_URI)
  }
}

usage:
migrate up --store=./migrate.js
migrate down --store=./migrate.js

@qqilihq
Copy link
Member

qqilihq commented Jul 14, 2020

Many thanks for posting this here -- to be honest, we do not use the “pure” CLI of migrate at all, but invoke it through the API, so this hadn’t even occurred to me. Good to see this alternative! :-)

I’ll update the readme with your example!

@qqilihq qqilihq reopened this Jul 14, 2020
@qqilihq
Copy link
Member

qqilihq commented Jul 14, 2020

TODO: Update readme.md

@retani
Copy link
Author

retani commented Jul 14, 2020

we do not use the “pure” CLI of migrate at all, but invoke it through the API

This info is somehow missing from https://github.com/tj/node-migrate as well.

I finally added "migrate:up": "migrate up --store=./migrate.js" to scripts in package.json, so in the command that I actually run in CLI is npm run migrate:up. It's almost like migrations in Ruby on Rails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants