foreign keys not getting generated
Closed this issue · 8 comments
Hi there, it worked great, thanks for your work.
I've got an issue, the foreign keys are not getting generated automatically. I checked the example configuration you put on readme but not sure about it.
Any help would be appreciated.
Hi @samrahman Could you please provide a small example of the table structure?
By default FK migrations are not enabled.
https://github.com/odan/phinx-migrations-generator#migration-configuration
Is this key enabled in your config file?
'foreign_keys' => true,
Not too sure about the config file, all I use is phinx.yml file? Do I need to create anything else? Where do I put it?
Here you find a phinx.php configuration file.
The configuration in phinx.yml
should work like this:
paths:
migrations: /your/full/path
foreign_keys: true
Thanks, with phinx.php, foreign keys are generated.
I've tried phinx.yml
first as you mentioned above, which didn't work unfortunately. Would have been great, as yml is more cleaner.
Having same issue. Setting the
paths:
migrations: /your/full/path
foreign_keys: true
in .yml file does not work. Do I net to create a .php file in my root directory and manually change the db parameters? All different environments are set in the yml file so... if I want to do movements on two or more environments, do I have to change the phinx.php file every time?
// Get PDO object
$pdo = new PDO(
'mysql:host=127.0.0.1;dbname=test;charset=utf8', 'root', '',
array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_PERSISTENT => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8 COLLATE utf8_unicode_ci',
)
);
Sorry, my example from above was not correct. The key foreign_keys
must be placed like in this example:
paths:
migrations: '%%PHINX_CONFIG_DIR%%/resources/migrations'
seeds: '%%PHINX_CONFIG_DIR%%/resources/seeds'
foreign_keys: true
environments: