5

Is the Doctrine Migrations project compatible with Doctrine MongoDB?

It isn't clear to me from searching and looking at the Doctrine Migrations project whether it is compatible with ODM solutions (e.g. MongoDB) as well as ORM solutions.

If it is, can anyone suggest examples or articles on how to use the two together?

If it isn't, are there reasonable alternatives?


Question Background:

I understand, marginally, the different approaches to migrating a document's data from one version of the document to another and the pros and cons of each.

I am leaning towards possibly implementing a hybrid approach of gradual schema changes and migration scripts as suggested here. Leveraging the functionality within Doctrine's MongoDB library written about by Jonathan Wage in his post: Doctrine MongoDB ODM Schema Migrations.

Even with that, I need to find some way of creating a migration script or performing the data migration, and Doctrine Migrations seemed like a good first choice.

As an aside, another user warns against using the approach Jonathan Wage presents above for migrating data and instead running commands (JavaScript?) directly against the database.

Community
  • 1
  • 1
Sean Quinn
  • 2,131
  • 1
  • 18
  • 48

2 Answers2

2

Despite doctrine-migrations is not compabible with MongoDB ODM (it only supports DBAL) you can bet for the alternative mongo-based migration components made by 3rd party teams.

It was firstly developed here https://github.com/antimattr/mongodb-migrations but after it has been abandoned the project continues here https://github.com/doesntmattr/mongodb-migrations

manuelbcd
  • 3,106
  • 1
  • 26
  • 39
  • Interesting. I'll have to keep an eye on this. I've been managing migrations manually with JavaScript files up until now. – Sean Quinn Jul 04 '17 at 13:53
  • There are 2 ways in mongo. One is the lazy migration (manage different document versions by code) and the other is to use migration scripts. This second one is tricky for huge ammounts of data if you don't want to go offline for long periods. – manuelbcd Jul 04 '17 at 14:11
  • Yeah, I'm familiar with the first approach, but I've never been really comfortable with it. It might be a better approach for me to take though in 9 out of 10 cases. Thanks for your thoughts! – Sean Quinn Aug 07 '17 at 23:08
0

Ufortunately, it isn't compatible with ODM. It supports ORM only.

Serhii Smirnov
  • 1,338
  • 1
  • 16
  • 24