migrations icon indicating copy to clipboard operation
migrations copied to clipboard

Support migrations for multiple databases within same project

Open JRDuncan opened this issue 5 years ago • 3 comments

This is a (multiple allowed):

  • [ ] bug

  • [x] enhancement

  • [ ] feature-discussion (RFC)

  • CakePHP Version: CakePHP 3

  • Migrations plugin version: .

  • Bake plugin version (if relevant):

  • Database server (MySQL, SQLite, Postgres): N/A

  • PHP Version:

  • Platform / OS:

What you did

Support migrations for multiple databases within same project Add migration directory as part of database config in app.config Migration directory is linked to connection Each migration is placed in directory associated with specific database user specifies connection when performing migration actions (create, migrate, rollback etc)

Expected Behavior

Support migrations for multiple databases within same project

Actual Behavior

To Do

JRDuncan avatar Nov 29 '19 21:11 JRDuncan

This would be insanely useful since it's now a real hassle to 'hack' migrations to work for multiple databases. We use it locally and in the pipeline and had to write custom scripts to enable this.

Danoctum avatar Dec 13 '19 14:12 Danoctum

I find it a very good idea too.

In app.php, a connection would be per default like:

className' => Connection::class,
'driver' => Mysql::class,
'persistent' => false,
'timezone' => 'UTC',
//'encoding' => 'utf8mb4',
'flags' => [],
'cacheMetadata' => true,
'quoteIdentifiers' => false,
'log' => false,
'migrationSources' => [
   CONFIG . 'Migrations',
],

migrationSources could be modified, or extended.

If a source is specified by the bake command, migrationSources get overwritten. If a plugin is specified, migrationSources are ignored. If a connection only is specified, or connection is default, migrationSources apply.

If this is matches your expectations, I can give the implementation a try.

pabloelcolombiano avatar Nov 09 '20 22:11 pabloelcolombiano

@pabloelcolombiano You still want to follow up on this?

dereuromark avatar Feb 21 '24 06:02 dereuromark