Hello,

I work on a drupal 7 site where hundreds of taxonomy terms were migrated into a vocabulary a few years back. A custom module was created for this purpose and a static class was derived from the Migration class (meaning the constructor does not take any arguments). The source database table was created in the drupal database and is still available.

I would like to import additional taxonomy terms into the same vocabulary. Can I reuse this work by simply inserting my rows into the existing table and running $drush mi <migration_machine_name>? In my local environment, I truncated the table and inserted a single row. The migration worked. However, because I’m running multiple migrations, I’m wondering if I should create a separate class to support dynamic migrations? I'll need to run another migration again in the near future. If I need to create a new class, I’ll change the source to use csv files like in migrate_baseball_example.

Thank you,
Ann

Comments

tenken’s picture

Why reuse the class as-is?

I recommend updating to the latest stable migrate module and then defining a new migration group for your new tasks. Then copy and fix your old class code to work with the newest migrate api and also make it use CSV data, in a new migration class.

Take the time to learn the current stable migrate api, learn to create a simple migration ... You'll grow as a developer and your site will be more maintainable.

mikeryan’s picture

Status: Active » Postponed (maintainer needs more info)

By "multiple migrations" you just mean running the same migration multiple times, correct? All you have to do is add new content to the source table you originally used, then rerunning the migration will import that new content, no problem.

ann b’s picture

@mikeryan: Thank you, this worked perfectly. Yes, I just need to run the same migration multiple times. I wasn't sure if I needed to create a dynamic migration. I suggest the following small change to the first paragraph of the Dynamic migrations documentation page:

Generally, all you need to do is define a Migration class with a hard-coded source and destination. In this case, there is a one-to-one correspondence between the class implementation, and a migration process (one row in drush migrate-status, one migration that can be run). If using a sql source, this same migration can be run multiple times by inserting the additional rows into your source table.) However, sometimes you may want to be able to migrate more than one set of source data using one implementation - for example, when migrating multiple blogs of the same form into Drupal. In this case, you need to set your migration up as a dynamic migration - a single migration class that can be instantiated multiple times because you need to pass in the different sources of the data to the migration object constructor..

Thank you also @tenken. The need for additional migrations will arise in the near future, guaranteed. I will switch the new migrations to use the latest recommended version of the migrate module and CSV files as the source.

ann b’s picture

Title: Running Multiple Migrations » How to run the same migration multiple times
Status: Postponed (maintainer needs more info) » Active
mikeryan’s picture

Title: How to run the same migration multiple times » Update or remove Dynamic Migrations page
Status: Active » Fixed

That page was obsolete, a relic of when DynamicMigration was a separate class and dealing with "dynamic" migrations was a special thing - I've now removed it so it won't cause further confusion. Now all migrations are "dynamic" and it doesn't need to be discussed separately, all the relevant information on how to register classes is at https://www.drupal.org/node/1824884.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.