I am trying to run migrations from a module's install file.
When installing the module, imports do not appear to be processed and no content is created.
When copy/pasting the below code in Devel's Execute PHP block it works, imports are processed and content is created.
migrate_get_module_apis(TRUE);
$migrations = array(
'Smallprint',
'Page',
'Service',
'Link',
'Testimonial',
'Blog'
);
foreach ($migrations as $machine_name) {
$migration = Migration::getInstance($machine_name);
$migration->processImport();
}
Any ideas why this does not work in an install file, whilst it works using Devel's Execute PHP block?
To reproduce, create module:
mymigratetest.info
name = My Migrate Test
description = Imports Migrate Example content.
core = 7.x
dependencies[] =migrate_examplemymigratetest.module
<?php
mymigratetest.install
<?php
function mymigratetest_install() {
$migrations = array(
'BeerTerm',
'BeerUser',
'BeerNode',
'BeerComment'
);
foreach ($migrations as $machine_name) {
$migration = Migration::getInstance($machine_name);
$migration->processImport();
}
}Installation of the module will not create content, whereas installing migrate_example and pasting the below code in Devel's Execute PHP block will.
$migrations = array(
'BeerTerm',
'BeerUser',
'BeerNode',
'BeerComment'
);
foreach ($migrations as $machine_name) {
$migration = Migration::getInstance($machine_name);
$migration->processImport();
}Any ideas why this does not work in an install file, whilst it works using Devel's Execute PHP block?
Comments
Comment #1
craiggardener commentedIgnore me. Turns out I hadn't pushed my latest commits to the server. It does work!
Closing this issue as it turned out to be an issue problem between my keyboard and chair rather an in issue with the module!
Comment #2
craiggardener commentedIt appears to not work.
I don't know why I thought it worked earlier.
I've moved the module to a new site, installed necessary content types, migrations are registered and migrations work from Migrate UI or by executing the code using Devel, however attempting to install this custom module results in a white screen of death.
Any ideas/help would be much appreciated.
Comment #3
craiggardener commentedProblem In Chair, Not In Code
Comment #4
PI_Ron commentedHi Craig,
What was your solution?
Classic reading btw.