Supports groupings of migrations which can easily be run together. Similar to lists like structure-tables and skip-tables in sql commands.

Comments

mikeryan’s picture

Component: Code » Drush
Category: bug » feature
mikeryan’s picture

Bump... This concept is more interesting to me now in the context of #989200: Dynamic migrations (and the project that inspired it). Although I would like to see an implementation of grouping in the module itself, rather than just in drush. E.g., separate the groups on the migrate_ui dashboard (tabs? fieldsets?)...

mikeryan’s picture

Title: Migration sets in drushrc.php » Migration sets/groups
mikeryan’s picture

Status: Active » Fixed

I've committed support for migration groups to D6 and D7. You can declare your migration to be part of a group by passing a group instance to the Migration(Base) constructor:

class ExampleMigration extends Migration {
  public function __construct() {
    parent::__construct(MigrateGroup::getInstance('example'));
    ...

This makes ExampleMigration a part of the 'example' group. If you pass no argument to parent::__construct(), your migration will be part of the 'default' group. You may also pass an optional array of group names as the second argument to MigrateGroup::getInstance(), so this group will be ordered after those groups. See wine.inc in migrate_example for a concrete example.

You can then run all the migrations in a given group with one command:

drush migrate-import --group=example

drush migrate-status, and the migrate_ui dashboard, will order migrations according to the defined groups and their dependencies.

parallax’s picture

Status: Fixed » Active

Strange, that doesn't work for me.

Error Message: PHP Fatal error: Class 'MigrateGroup' not found in /Users/trick/Sites/bt/sites/all/modules/custom/bt_redaktion/bt_redaktion.module on line 5

In fact, I can't find any MigrateGroup Class.

class bt_redaktionMigration extends Migration {
	public function __construct() {
		parent::__construct(MigrateGroup::getInstance('bt'));
		$this->description = t('Bielertagblatt Redaktionsnews');
		$query = db_select('bt_redaktion_online', 'b')	
			->fields('b', array('articleId','title', 'lead', 'content', 'priority', 'authorId', 'views'))
			->condition('authorId',1,'>');

		$this->source = new MigrateSourceSQL($query);
		$this->destination = new MigrateDestinationNode('bt_article');
		
		$this->map = new MigrateSQLMap($this->machineName,
			array(
				'articleid' => 
					array(
						'type' => 'int',
						'unsigned' => TRUE,
						'not null' => TRUE,
					)
			),
			MigrateDestinationNode::getKeySchema()
		);
    
		$this->addFieldMapping('title', 'title');
    $this->addFieldMapping('field_lead', 'lead')
    	->arguments(array('language' => 'de'));
    $this->addFieldMapping('body', 'content')
    	->arguments(array('language' => 'de'));
    $this->addFieldMapping('field_priority', 'priority')
    	->arguments(array('language' => 'de'));
    $this->addFieldMapping('field_origin', 'dummy')
	    ->arguments(array('language' => 'de'))
    	->defaultValue('bt');
  }
}
mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

@patrick.sifneos: What precise version of migrate are you using? Are you using 2.2 RC1, or a -dev version pulled since July 10? And, assuming you have pulled a new version of Migrate since then, did you do a "drush cc all" to make sure the code registry was rebuilt and new classes recognized? Do you have the file includes/group.inc?

mikeryan’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No further info provided.