2017 © Pedro Peláez
 

drupal-module up-migrate

Provides some migration plugins and helpers

image

undpaul/up-migrate

Provides some migration plugins and helpers

  • Monday, February 19, 2018
  • by derhasi
  • Repository
  • 4 Watchers
  • 0 Stars
  • 1,939 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 8 % Grown

The README.md

undpaul Migrate

This project aims to give you a jump-start on building migrations., (*1)

Installation

Clone the project into modules/custom of your Drupal installation and run composer install within the modules directory., (*2)

Usage

up_migrate comes with some base classes and tools useful for building migrations., (*3)

ID maps

FastSql

Since the mapping tables create by Migrate do not have proper unique indexes, the ID map "fastsql" alters the definitions of the map tables and add proper indexes. This increases migration performance significant. up_migrate sets the ID map for all migrations if they do not specify the property idMap for themself., (*4)

Source plugins

up_migrate comes with a set of pre-defined source plugins., (*5)

SqlBase

The abstract class \Drupal\up_migrate\Plugin\migrate\source\SqlBase is meant to be the parent class for all custom migration sources. It allows configuring sources from directly within a migration yml-file., (*6)

Example for definition in migrate_plus.migration.{id}.yml:, (*7)

source:
  table:
    name: users
    alias: u
    ids:
      uid: integer

This sets the base table of the migration source to a table named "users". The table can be referenced by using the alias "u" and have one unique key named "uid"., (*8)

Example for definition in custom source plugin (must extend SqlBase), (*9)

/**
 * @MigrateSource(
 *   id = "upm_examples__user",
 *   table = {
 *     "name": "users",
 *     "alias": "u",
 *     "ids": {
 *       "uid": "integer"
 *     }
 *   }
 * )
 */

For more complex ID definitions simply override the function getIds()., (*10)

Adding additional databases as migration source

Usually you want to migrate data from one or more existing databases to your new site. To be able to reference these source databases in your migrations, simply run the following drush command, (*11)

drush upm-da {key} {database name} --username={name} --password={password}

For more information about the command and its options run drush help upm-da., (*12)

In your migration yml-file (or in your source class) set the key of the database to use, (*13)

source:
  key: 'database-key-from-above'

The source plugin SqlBase will automatically switch to the new database and fetch all data from there., (*14)

Stream wrapper

up_migrate provides a custom read-only stream wrapper to access files needed for migrations in a handy way., (*15)

To setup the correct directoy to your migration files, add the following code to your settings.php, (*16)

// Set private folder.
$settings['file_migration_source_path'] = '/path/to/migration/files';

The Versions

19/02 2018

dev-8.x-3.x

dev-8.x-3.x

Provides some migration plugins and helpers

  Sources   Download

GPLv3 GPL-3.0-only