0

I use 'doctrine/DoctrineORMModule' module for zend framework 3 (MVC). I have configured 'orm_default' and can configure 'orm_old' but don't know how to use 'orm_old' within migration file.

I can do this within migration file:


public function up(Schema $schema) : void
{
    $sql = "INSERT INTO `some_table` VALUES ('some_value','','',NULL,NULL,'1');";

    $this->addSql($sql);
//...

But in general I need run something like this:

INSERT INTO DB2.T2(id, title, description) 
SELECT id, title, description FROM DB1.T1;

How to do that?

webprogrammer
  • 2,393
  • 3
  • 21
  • 27

1 Answers1

1

If I understand correctly, you'd like to use Doctrine Migrations for two database connections: orm_default and orm_old.

This is possible in Doctrine, but not with the Zend Framework DoctrineORMModule. This is mentioned very shortly in the official documentation: https://github.com/doctrine/DoctrineORMModule/blob/master/docs/migrations.rst#multiple-migration-configurations

The best thing you can do is to use two separate cli-config files with the same database connections, and put the migrations in two seperate folders. You can then use the 'default' doctrine CLI tools (vendor/bin/doctrine migrations:migrate ) to run migrations for the two connections.

Adding this functionality to the DoctrineORMModule was requested, but never implemented. You can read more about it right here: https://github.com/doctrine/DoctrineORMModule/issues/537

Frank Houweling
  • 595
  • 5
  • 14