How To Handle Custom Drupal Migration Using SQLBase?

How To Handle Custom Drupal Migration Using SQLBase?

How To Handle Custom Drupal Migration Using SQLBase?

The field of Drupal migrations is a hive of activity. On November 1, 2023, Drupal 9 reached its End of Life (EOL). The final extension for Drupal 7 is January 2025, when it will go EOL. Drupal 10.1.6, the most recent version, was released on November 1, 2023, following the release of Drupal 10 in December 2022. Based on the download statistics for the Upgrade Status module, over 12,000 sites have already made the switch to the most recent version of Drupal 10.

We’ll go over the various Drupal migration techniques in this post, with a special emphasis on custom migrations that make use of the SqlBase source plugin. Look at this!

In Technical Terms, What is a Drupal Migration?

The process of migrating content, data, and configuration from a previous version of Drupal or another CMS to Drupal is known as Drupal migration. The phases of a migration are Extract, Transform, and Load (ETL). These are known as source, process, and destination plugins in the Drupal community. The source is the extract phase, the process is the transform phase, and the destination is the load phase.

Drupal Migration Methods

There are basically two ways you can migrate your website from Drupal 7 to Drupal 9 or a later version.

  • Migration UI 
  • Drush (Custom migration)

Migration UI 

Migration UI may be used to move your complete web application—including all settings and content—to a newer version. It’s an easy choice that doesn’t necessitate a deep understanding of Drupal APIs. When your website’s architecture isn’t very complicated and all of the Drupal 7 modules are compatible with the target version (Drupal 9 or Drupal 10), you can use this strategy.

Custom Migration

Migration UI just won’t function when you are rebuilding your website from Drupal 9 using a more contemporary and performance-focused strategy, which necessitates considerable modifications to the architecture of your new website. In situations like this, you’ll have to get your hands dirty and write custom migration scripts.

Migration Process

Let’s examine the migration procedure in more detail. There are three main processes involved.

  • Source plugin (Extract)
  • Process plugin (Transform)
  • Destination plugin (Load)

Source Plugin

The extraction of data from a variety of sources—including databases, CSV/XML/JSON files, and raw data—is handled via source plugins. They take data from these sources and transfer it to the following stage of the migration procedure.

Process Plugin

Working with the original data, the process plugin restructures it to fit the destination process. The information is converted into an array, with each key denoting a certain destination attribute. The destination values for your new website are generated based on the values that are assigned to each key.

Further information is available here.

Destination plugin

The structured data is processed by the destination plugin and saved to your website. Node, keyword, user, and media destination plugins are the most often used ones.

Most likely, you understand how the migration works. Let’s take a closer look at source plugins now, concentrating on the SqlBase source plugin.

Using SqlBase for the Drupal Migration

What is SqlBase migration?

The conversion process for SqlBase is simple, as it gives you the freedom to craft bespoke SQL queries to get the necessary results. Apart from that, it adheres to the same guidelines as previous Drupal migration techniques.

Why should you use SqlBase Migration?

Drupal core migration is capable of handling sites with simple content types, field structures, etc. However, issues with out-of-date Drupal 9 field types or when redesigning an outdated website with a variety of content kinds can develop. A straightforward move is insufficient if your goal is an editor-friendly, performance-focused website. To migrate your data from SqlBase, you must first prepare your source data.

In another case, SqlBase migration is also the best option if the data on your existing website, which was developed on a platform other than Drupal, is stored in a database.

Benefits of leveraging SqlBase Migration

Because this is SqlBase, the quality of your database queries will determine how quickly your migration completes. The sooner the migration proceeds, the better your query preparation.

You are free to manipulate and handle your data anyway you see fit; it doesn’t rely on many essential migration procedures.

These three techniques need to be implemented by the SqlBase Source Plugin:

  • query(): Returns the SQL query that selects the data from the source database.
  • fields(): Returns available fields on the source.
  • getIds(): explains how to define the source fields that make up a source row.

Let’s examine the specifics of what these functions ought to include:

query() function

/**

* {@inheritdoc}

*/

public function query() {

$query = $this->select(‘job_details’, ‘c’)

  ->fields(‘c’, array(

    ‘id’,

    ‘title’,

    ‘description’,o

    ‘position’,

    ‘company’,

    ‘criteria’,

  ));

return $query;

}

 

fields() function

/**

* {@inheritdoc}

*/

public function fields() {

$fields = array(

  ‘id’= $this->t(‘Autoincrement ID’),

  ‘title’ = $this->t(‘Job Title’),

  ‘description’ = $this->t(‘Job Description’),

  ‘position’ = $this->t(‘Job Position’),

  ‘company’.= $this->t(‘Company’),

  ‘criteria’ = $this-»t(‘Job Criteria’),

);

return $fields;

}

 

getIds() function

/**

* {@inheritdoc}

*/

public function getIds() {

return [

  ‘id’ => [

  ‘type’ => ‘integer’,

  ‘alias’=>’j’

];

}

 

The prepareRow() function also allows you to modify your SQL result and even add new source properties to your migration.

/**

* {@inheritdoc}

*/

public function prepareRow(Row $row) {

$company = $row->getSourceProperty(‘company’);

 

$row->setSourceProperty(‘job_type’, ‘on-site’);

if ($company == ‘appicsoftwares’) {

  $row->setSourceProperty(‘job_type’, ‘remote’);

return parent::prepareRow($row);

}

If you would like to process your source data further, you can use your own processor; these source properties will also be delivered to your migration yml files.

Final Thoughts

There has never been a more urgent need for smooth migrations with the EOL of Drupal 9, the approaching retirement of Drupal 7, and the ascent of Drupal 10. Our Drupal Development Company understands that SqlBase is a necessary tool for a smooth and effective migration procedure as Drupal develops. Providing the ability to customize SQL queries, it is essential for creating customized data transitions.

Get Free Consultation Now!


    Contact Us

    Consult us today to develop your application.

      Get in touch with us


      Skype Whatsapp Gmail Phone