cakephp / migrations

CakePHP database migrations plugin
Other
137 stars 115 forks source link

Not abel to specifie the Database to use in the Migration #739

Open Tyqo opened 3 weeks ago

Tyqo commented 3 weeks ago

This is a (multiple allowed):

Hi, so I am rewriting an older Project with CakePHP an I have been enjoying Migrations. The Problem is, that this Project is using 7 Databases, which won't be a problem with Cake.

But, I can't set the Database for a specific Migration. I can run the Migration with the -c flag, but it still tries to apply all other Migrations to that Database. Am I missing something here? Or is the Migrations Plugin not suitable for multiple Databases?

dereuromark commented 3 weeks ago
  -p, --plugin=PLUGIN          The plugin containing the migrations
  -c, --connection=CONNECTION  The datasource connection to use
  -s, --source=SOURCE          The folder where migrations are in

You could try to use -c together with either -s (different source path) or -p (plugin based source separation). That would work I guess.

markstory commented 3 weeks ago

Am I missing something here? Or is the Migrations Plugin not suitable for multiple Databases?

Migrations can work with multiple databases, but what it doesn't understand is which tables are in which databases. It does however give a few tools for grouping migrations together. Currently we have 'sources' and plugins as ways to create sub-groups of migrations that can be run independently. @dereuromark's suggestion of pairing connections + source directories together could be a good solution for separating migrations for each of your databases.