Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Doctrine migration diff from deleting tables

I'm currently in the process of "Doctrinizing" an large existing database. This process is working very well and we're slowly able to substitute the old raw query code with entities and DQL.

We recently discovered the awesome Doctrine Migrations project which seems like the perfect candidate to manage the changes to our database. We've run into a bit a a snag however.

Our database is quite large and we're refactoring aspects of our application bit by bit. We currently have about 40% of the database represented as entities. The problem is that when we run a "diff" on the partially converted database, the diff wants to drop a whole lot of tables because no entities exist for those tables. We can edit the diff manually but it will become quite cumbersome and potentially error prone.

The question is; it it possible to create a diff and tell the diff process not to drop any tables for which no entities exist?

like image 767
Luke Avatar asked Apr 09 '14 01:04

Luke


1 Answers

If you are working with Symfony2, you just can add the configuration like documented here: http://symfony.com/doc/current/bundles/DoctrineMigrationsBundle/index.html#manual-tables

On per-command basis you can specify a regex for those tables that should be accounted for diff, like:

app/console doctrine:migrations:diff --filter-expression=/^t_/

(will generate diff only for those tables whose name starts with t_ and ignore the other).

like image 164
Actine Avatar answered Sep 24 '22 09:09

Actine