We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Database Migration

First of all, I would like to say that the docs are outdated: https://docs.phalcon.io/en/latest/reference/migrations.html

Instead of: phalcon gen-migration we now have: phalcon migration generate, and so on.

One feature that would help me a lot is specifying the output folder for the migration. So by using --directory I would expect to be able to specify that. INstead, no matter what path I give(full, relative) it always appends: "app/migrations" to the path. Bug?



8.6k

Same goes for specifying the output folder when generating a model.



8.6k

More on migration:

The following code(excerpt):

'references' => array(
                new Reference('ibfk_2', array(
                    'referencedSchema' => 'dbschema',
                    'referencedTable' => 'table1',
                    'columns' => array('column1_id'),
                    'referencedColumns' => array('id')
                )),
                new Reference('ibfk_3', array(
                    'referencedSchema' => 'dbschema',
                    'referencedTable' => 'table2',
                    'columns' => array('column2_id'),
                    'referencedColumns' => array('id')
                ))
            ),

Generates this Mysql query, which doesn't work:

CREATE TABLE `dbschema`.`table` (  `column1_id` INT(10) UNSIGNED NOT NULL,  `column2_id` INT(10) UNSIGNED NOT NULL  PRIMARY KEY (`column1_id`, `column2_id`),  KEY `column1_id` (`column1_id`),  CONSTRAINT `ibfk_2` FOREIGN KEY (`id`) REFERENCES `column1_id`(`id`),  CONSTRAINT `ibfk_3` FOREIGN KEY (`id`) REFERENCES `column2_id`(`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci

The problem is that:

CONSTRAINT `ibfk_2` FOREIGN KEY (`id`) REFERENCES `column1_id`(`id`),

should be:

CONSTRAINT `ibfk_2` FOREIGN KEY (`column1_id`) REFERENCES `column1_id`(`id`),


8.6k

And one last thing: what happend to table data migration? In the docs there is an: --export-data param, but that seems to be gone now.



762

UP! Can you please fix this bug with FOREIGN KEYS!!!

UP again! Please address this issue.

You can create an issue in the devtools repository to report or fix this: https://github.com/phalcon/phalcon-devtools