Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

MongoDB Migrations #52

Closed
naartjie opened this issue May 7, 2014 · 4 comments
Closed

MongoDB Migrations #52

naartjie opened this issue May 7, 2014 · 4 comments

Comments

@naartjie
Copy link

naartjie commented May 7, 2014

The convo from Twitter.

I was thinking of migrations a-la Rails or Fuel PHP.

Could base something on the relatively simple and abstract migrate framework. I tried using mongo-migrate, as well as a command line tool, but I've had no luck with either.

This might be something which is best left as un-opinionated by the stack though, and let the users choose their own tool, but still I like the idea of having the convenience of db migrations right there available to me by default when I'm using mean.

What do you guys think?

@amoshaviv
Copy link
Contributor

Hi @naartjie,

This is an interesting idea since db migrations is usually a painful task. However I'm also not sure it would be best to include this in the core, so I'll mark it as an enhancement for the moment. We'll share this feature with the community and see what they think.

Cheers,
Amos

@martiserra
Copy link

Hi @naartjie, @amoshaviv,

I am just starting my first project with the MEAN stack, and I was thinking about kind of rails migration as well. Though I'm a experienced developer, I am relatively new to Javascript in the backend and the MEAN stack, so I would like to share here my thoughts regarding this topic and collect your feedback.

When talking about migrations I was thinking 2 types of migrations: schema migrations and data migrations, and the ability to versioning all of that.

  • Regarding schema migrations, since we're using Mongoose, I would say that the Schema does not reside in the database itself, but in the code, in every model we want persist to mongoDB. Thus, perhaps it makes no full sense to have migrations for that, since the code can be already versioned.
  • Regarding data migrations, I can imagine different uses cases that might be interesting, but probably all of them can be run with node-migrate framework:
    • Modifying all of the documents of a collection once its schema has been changed through code.
    • Adding kind of initial or static data to some collections for which you don't want to build the full CRUD

What is your view on that?

Cheers,
Martí

@naartjie
Copy link
Author

Hi @martiserra and welcome to MEAN ;-)

You know what, I think you are right, I'm just having a browse through node-migrate, and it looks like not much is required to get it to work with Mongo.

I do think this is outside the scope of MEAN, and we should probably roll something independently. Let's keep each other updated if we do start something ;)

@NeverOddOrEven
Copy link
Contributor

I have added migration support to my projects using the mongodb driver and migrate (javascript w/ callbacks). I don't think adding migrations support is overly opinionated, especially since it can be done in isolation. I would advocate for a javascript solution over rails simply to maintain consistency, but I have heard rails has more advanced migration features.

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

No branches or pull requests

4 participants