Custom table migration from Drupal 7 to 8

26 / Dec / 2022 by Yogesh Pratap Singh 0 comments

Custom table migration is slightly different from Content migration. We can migrate Custom table data from Drupal 7 to 8 by using simple steps. Before discussing those steps, we should know which modules are necessary to migrate data.

Necessary modules

  1. Migrate
  2. Migrate Drupal
  3. Migrate Drupal UI
  4. Migrate Plus
  5. Migrate Tools
  6. Drupal Upgrade

We can use these modules according to our requirements, a few more modules are also available for migration. So, let’s get back to the custom module migration. Let’s create a directory (Custom Table Migration) under our migration directory.

The structure will look like:

In the Custom Table Migration directory, we will create config & src directory with one yml file custom_table_migration.info.yml

In the custom_table_migration.info.yml file, we write our code like.

Now we need to create the main configuration file.

modules/custom_migration/custom_table_migration/config/install/migrate_plus.migration.d7_custom_school_migrate.yml

In the Destination section, we need to define plugin: table and table_name : custom_school_data

Now we will create a file for our Source Plugin. In this file, we need to implement both the query() and prepareRow() methods.

modules/custom_migration/custom_table_migration/src/Plugin/migrate/source/CustomSchoolData.php

In our case, we check whether the id is migrated or not if migrated, then we skip that data row.

So this is a simple example of custom table migration.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *