SlideShare a Scribd company logo
1 of 48
A pain free (sort of)
approach to the
Migraine (aka Migrate)
module.
Dennis Solis








Solis Media Group
Over 20 years of application software development.
Two years of Drupal development
Procedural php coder
Learning OO php
Do not understand the magic of OO
Migraine module helped
2
My Assignment


Migrate OA Beta to OA 1.4 on Drupal 6.

3
Data Migration Options




Move data by hand
Feeds and Feeds Tamper
Migrate module

4
Smoothing the Move






http://denver2012.drupal.org/program/sessions/
migration-smoothing-move
Analyze – understand the legacy data
Map – Line up source fields with destination fields
Iterate – try, try, again – until it works
Congratulations – you done

5
Feeds
No coding except for special conditions
Setup / execution is done via a UI
LOT easier to setup and use
Comes with a mapping screen.
It is limited









Receiving module needs to support feeds.
Does not support all fields but you can write code
to handle the fields.
6
Feeds
Works great
Limited by lack of field handlers
It is a bit slow






Especially for LOTS of data

Does not work well if




Different contents types that reference the other.

7
Feeds Tamper



Manipulate the data before processing
Works with Feeds

8
Migrate Module
Import data / contents into Drupal 6, 7, and 8
Migrate for Drupal 6 and 7 are about 95%
compatible









Drupal 6 – uses dbtng and autoload
Mapping is done in code
Very flexible
Much Faster

Migraine is here to stay.




It is in Drupal 8 core
9
Migrate


Migrate 2.0
New Migrate 7.2-x-dev - – released 10-01-2013
 Migrate 2.0 for D6 requires the autoload and dbtng
modules.




Migrate d 2 d




New Migrate 7.2-x-dev – released 10-01-2013

Migrate Extra – Sub-module within Migrate
10
Migrate D 2 D




Use this to migrate from 6 to 7 or 8
All the benefits and pain of the migrate module
Provides class specific to older versions of
Drupal.
It does a lot of the work that I had to do manually
 I could not use because I went D6 to D6.


11
Migrate OG


Only use if you are using Migrate 1.0



The Organic Group migration support for
Migrate 2.0 has been moved into Organic
Groups itself.

12
Drupalcon Denver
Andrew Morton stated the migrate module:








Two weeks of banging his head
Tricky to get started with
Steep learning curve
Inscrutable
Complex

13
Learning Cliff





Open Atrium
Open Atrium Data Structure
Migrate Module
OO Php

14
My Gifts to You





How to connect to multiple databases
Easily find the D6 source data structure
How to user the Migration UI
How to write migration code

15
Ease the pain






phpMyAdmin
Devel module
Migrate UI
Beer and Wine examples
Drush

16
phpMyAdmin




How to read the keys to the tables
Click on the index tab
Database search for data

17
Open Atrium Structure

18
OA Data Structure








Taxonomy
User and User Profile
Organic Group nodes
Books
Content Types
Comments
Case Tracker Data Structure
19
Tools you will need







Football helmet
A LOT of aspirins
Patience
Tenacity

A little bit of knowledge
A little OO
 A little migration code


20
Devel Module



Devel
Devel node acces

21
Migrate Module




Migrate UI
Migrate
Migrate Extras

22
Other Modules




dbtng – back ports many of the Drupal 7
database functions back to D 6
autoload – helper module to autoload
classes under PHP 5

23
OO definitions


An object is a self-contained component that
contains properties and methods needed to
make a certain type of data useful.


For example, in a project management application,
you would have a:
Status object
 Cost object
 Client object among others.


24
OO definitions




An object’s properties are what it knows. (This
of this as variables related to the object.)
Its methods are what it can do. (This if this as
functions or subroutines.)

25
OO definitions




A class is a blueprint or template or set of
instructions to build a specific type of object.
Every object is built from a class. Each class
should be designed and programmed to
accomplish one, and only one, thing.

26
OO definitions


An instance is a specific object built from a
specific class. It is assigned to a reference
variable that is used to access all of the instance's
properties and methods. When you make a new
instance the process is called instantiation and
is typically done using the new keyword.

27
OO definitions






A class is like a recipe for chocolate cake. The
recipe itself is not a cake. You can't eat the
recipe (or at least wouldn't want to).
If you correctly do what the recipe tells you to
do (instantiate it) then you have an edible cake.
That edible cake is an instance of the chocolate
cake class.

28
OO concepts






A class is like a recipe for chocolate cake. The
recipe itself is not a cake. You can't eat the
recipe (or at least wouldn't want to).
If you correctly do what the recipe tells you to
do (instantiate it) then you have an edible cake.
That edible cake is an instance of the chocolate
cake class.

29
Your Migrate Module


Migration should be in a SEPARATE
module
So you can turn it off once you are done.
 Isolate it if you are going to be doing ongoing
date based updates.


30
Migrate supports









Support multi-field or composite keys.
Tracks the source id and it’s final destination id
and you can access this information during your
migration.
Translate from the old key to the new key.
Can do a roll back.
Can re-do a migration and update those articles
in place.
Do “date” based ongoing migrations.

31
Migration class
Configure all of your pieces for the migration
 Selects the source data and map it to the
destination data.


32
Migration class


prepareRow(), prepare(), complete()
Allow you to manipulate the data or skip records
 Update other rows while migrating data




Writes out the destination data.

33
Migration class

34
Source data





Source data can be in SQL, CSV, XML, JSON
format
Need to have definition of these files.
I used the SQL format.

35
Field Handlers



A field definition within Drupal is an array structure
Converts simple string data into the Drupal array
structure

36
Destination Handlers






comments.inc
fields.inc
node.inc
table.inc
term.inc

entity.inc
file.inc
path.inc
table_copy.inc
user.inc

37
Destination




Migrate will write the Destination nodes for
you (node, user, other supported entities, or
SQL rows).
Create one destination record for each source
record

38
Order is critical





Must migrate user accounts before you can
migrate user profiles.
Know you data
Create a list of the sequence in which the data
is to be converted.

39
Migration Class





Everything is done in code
You write a “base class” from which you then
extend in your code. In this base class, you can
define things about this migration.
Everything you want to do is an extension of
an existing migrate class.

40
Migration Class





Inherit and extend these classes
You have to write a small module to “extend”
the classes.
Documentation is provided in the form of
code examples.
beer.inc
 wire.inc


41
Multiple DB in D6


Database select from within current
database:
*
$db_url = 'pgsql://username:password@localhost/databasename';
*/
*// - das - $db_url = 'mysqli://root@localhost/mis_project';
$db_url['default'] = 'mysqli://root@localhost/mis_project';
$db_url['legacy'] = 'mysqli://root@localhost/open_atrium_legacy';
$db_prefix = '';



Database select from within current
database:
$query = db_select('users_legacy', 'ul');

42
Multiple DB in D7


Define the database
Database::addConnectionInfo('jnn_xoops', 'default', array(
'driver' => 'mysql',
'database' => 'jnn_xoops',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'prefix' => '',
));



Define the query
$query = Database::getConnection('default', 'jnn_xoops')
->select('xoops_users', 'xu')
->fields('xu', array('uid', 'name', 'uname', 'email'));

43
My Module




Structure of my migration module was placed in
sites/all/modules/custom.
My module name is: migrate_mc_oa
migrate_mc_oa.info
 migrate_mc_oa.install
 migrate_mc_oa.module
 migrate_mc_oa.inc


44
My Module


Structure of my migration module
migrate_mc_oa_user.inc
 migrate_mc_oa_node_og.inc
 migrate_mc_oa_book.inc
 migrate_mc_oa_node_ct.inc
 migrate_mc_oc_comment.inc


45
My Module

46
Let’s see the code
class McOaBasicMigration extends McOaMigration {
public function __construct() {
parent::__construct();
$this->description = t('Descriptions');
$this->dependencies = array('Other_Migration_Dependencies');
$this->map = new MigrateSQLMap(....));
$query=db_select('comments_legacy', 'cl');
or
$query = Database::getConnection('default', 'legacy')
->select('comments', 'cl');
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationComment('comment_case_tracker_case');
$this->addFieldMapping('pid', 'pid');
$this->addFieldMapping('nid', 'nid')
->sourceMigration('McOaCaseCt');
// Unmapped destination fields
$this->addUnmigratedDestinations(array('fname', 'lname'));
47
Drush Migrate Cmds







https://drupal.org/node/1561820
drush migrate-import Article
drush migrate-import Article --limit="100 items"
drush migrate-import --all=User
drush migrate-import –rollback –all
drush migrate-import –update –group = [grp_name]

48

More Related Content

What's hot

What's hot (17)

Ado.net session05
Ado.net session05Ado.net session05
Ado.net session05
 
Database Basics and MySQL
Database Basics and MySQLDatabase Basics and MySQL
Database Basics and MySQL
 
Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
 
Android sq lite-chapter 22
Android sq lite-chapter 22Android sq lite-chapter 22
Android sq lite-chapter 22
 
What is SQL Server?
What is SQL Server?What is SQL Server?
What is SQL Server?
 
Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)Database Systems - Introduction to SQL (Chapter 3/1)
Database Systems - Introduction to SQL (Chapter 3/1)
 
Adbms
AdbmsAdbms
Adbms
 
Ado.net
Ado.netAdo.net
Ado.net
 
Doctrine 2 - Introduction
Doctrine 2 - IntroductionDoctrine 2 - Introduction
Doctrine 2 - Introduction
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | Edureka
 
Ebook12
Ebook12Ebook12
Ebook12
 
Ujjwalreverseengineeringppptfinal
UjjwalreverseengineeringppptfinalUjjwalreverseengineeringppptfinal
Ujjwalreverseengineeringppptfinal
 
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentation
 
Stata datman
Stata datmanStata datman
Stata datman
 
Rdbms concepts
Rdbms conceptsRdbms concepts
Rdbms concepts
 
Introduction to mysql part 1
Introduction to mysql part 1Introduction to mysql part 1
Introduction to mysql part 1
 

Similar to Pain-free approach to migrating with the Migrate module

SDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for ModulesSDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for ModulesAlvin Reyes
 
Migrating to Drupal 8
Migrating to Drupal 8Migrating to Drupal 8
Migrating to Drupal 8Alkuvoima
 
Drupalcampchicago2010.rachel.datamigration.
Drupalcampchicago2010.rachel.datamigration.Drupalcampchicago2010.rachel.datamigration.
Drupalcampchicago2010.rachel.datamigration.Promet Source
 
Android App Development 05 : Saving Data
Android App Development 05 : Saving DataAndroid App Development 05 : Saving Data
Android App Development 05 : Saving DataAnuchit Chalothorn
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPTAjay Chimmani
 
Tips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with DrupalTips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with DrupalMitzaCeusan
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptxLadduAnanu
 
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the RisksMigrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the RisksAcquia
 
Drupal Migrations in 2018
Drupal Migrations in 2018Drupal Migrations in 2018
Drupal Migrations in 2018Pantheon
 
Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02Gaurav Varshney
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8Dick Olsson
 

Similar to Pain-free approach to migrating with the Migrate module (20)

Data herding
Data herdingData herding
Data herding
 
Data herding
Data herdingData herding
Data herding
 
Migration to drupal 8.
Migration to drupal 8.Migration to drupal 8.
Migration to drupal 8.
 
SDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for ModulesSDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for Modules
 
Migrating to Drupal 8
Migrating to Drupal 8Migrating to Drupal 8
Migrating to Drupal 8
 
Migrate to Drupal 8
Migrate to Drupal 8Migrate to Drupal 8
Migrate to Drupal 8
 
Drupalcampchicago2010.rachel.datamigration.
Drupalcampchicago2010.rachel.datamigration.Drupalcampchicago2010.rachel.datamigration.
Drupalcampchicago2010.rachel.datamigration.
 
Android App Development 05 : Saving Data
Android App Development 05 : Saving DataAndroid App Development 05 : Saving Data
Android App Development 05 : Saving Data
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
Dashboard
DashboardDashboard
Dashboard
 
Tips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with DrupalTips and tricks for building Large web applications with Drupal
Tips and tricks for building Large web applications with Drupal
 
Migrate
MigrateMigrate
Migrate
 
BD-zero lecture.pptx
BD-zero lecture.pptxBD-zero lecture.pptx
BD-zero lecture.pptx
 
Obevo Javasig.pptx
Obevo Javasig.pptxObevo Javasig.pptx
Obevo Javasig.pptx
 
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the RisksMigrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
Migrating to Drupal 8: How to Migrate Your Content and Minimize the Risks
 
BD-zero lecture.pptx
BD-zero lecture.pptxBD-zero lecture.pptx
BD-zero lecture.pptx
 
Drupal Migrations in 2018
Drupal Migrations in 2018Drupal Migrations in 2018
Drupal Migrations in 2018
 
Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02
 
Drupal6 and Drupal 7 difference
Drupal6 and Drupal 7 differenceDrupal6 and Drupal 7 difference
Drupal6 and Drupal 7 difference
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8
 

Recently uploaded

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Pain-free approach to migrating with the Migrate module

  • 1. A pain free (sort of) approach to the Migraine (aka Migrate) module.
  • 2. Dennis Solis        Solis Media Group Over 20 years of application software development. Two years of Drupal development Procedural php coder Learning OO php Do not understand the magic of OO Migraine module helped 2
  • 3. My Assignment  Migrate OA Beta to OA 1.4 on Drupal 6. 3
  • 4. Data Migration Options    Move data by hand Feeds and Feeds Tamper Migrate module 4
  • 5. Smoothing the Move      http://denver2012.drupal.org/program/sessions/ migration-smoothing-move Analyze – understand the legacy data Map – Line up source fields with destination fields Iterate – try, try, again – until it works Congratulations – you done 5
  • 6. Feeds No coding except for special conditions Setup / execution is done via a UI LOT easier to setup and use Comes with a mapping screen. It is limited        Receiving module needs to support feeds. Does not support all fields but you can write code to handle the fields. 6
  • 7. Feeds Works great Limited by lack of field handlers It is a bit slow     Especially for LOTS of data Does not work well if   Different contents types that reference the other. 7
  • 8. Feeds Tamper   Manipulate the data before processing Works with Feeds 8
  • 9. Migrate Module Import data / contents into Drupal 6, 7, and 8 Migrate for Drupal 6 and 7 are about 95% compatible       Drupal 6 – uses dbtng and autoload Mapping is done in code Very flexible Much Faster Migraine is here to stay.   It is in Drupal 8 core 9
  • 10. Migrate  Migrate 2.0 New Migrate 7.2-x-dev - – released 10-01-2013  Migrate 2.0 for D6 requires the autoload and dbtng modules.   Migrate d 2 d   New Migrate 7.2-x-dev – released 10-01-2013 Migrate Extra – Sub-module within Migrate 10
  • 11. Migrate D 2 D    Use this to migrate from 6 to 7 or 8 All the benefits and pain of the migrate module Provides class specific to older versions of Drupal. It does a lot of the work that I had to do manually  I could not use because I went D6 to D6.  11
  • 12. Migrate OG  Only use if you are using Migrate 1.0  The Organic Group migration support for Migrate 2.0 has been moved into Organic Groups itself. 12
  • 13. Drupalcon Denver Andrew Morton stated the migrate module:       Two weeks of banging his head Tricky to get started with Steep learning curve Inscrutable Complex 13
  • 14. Learning Cliff     Open Atrium Open Atrium Data Structure Migrate Module OO Php 14
  • 15. My Gifts to You     How to connect to multiple databases Easily find the D6 source data structure How to user the Migration UI How to write migration code 15
  • 16. Ease the pain      phpMyAdmin Devel module Migrate UI Beer and Wine examples Drush 16
  • 17. phpMyAdmin    How to read the keys to the tables Click on the index tab Database search for data 17
  • 19. OA Data Structure        Taxonomy User and User Profile Organic Group nodes Books Content Types Comments Case Tracker Data Structure 19
  • 20. Tools you will need      Football helmet A LOT of aspirins Patience Tenacity A little bit of knowledge A little OO  A little migration code  20
  • 23. Other Modules   dbtng – back ports many of the Drupal 7 database functions back to D 6 autoload – helper module to autoload classes under PHP 5 23
  • 24. OO definitions  An object is a self-contained component that contains properties and methods needed to make a certain type of data useful.  For example, in a project management application, you would have a: Status object  Cost object  Client object among others.  24
  • 25. OO definitions   An object’s properties are what it knows. (This of this as variables related to the object.) Its methods are what it can do. (This if this as functions or subroutines.) 25
  • 26. OO definitions   A class is a blueprint or template or set of instructions to build a specific type of object. Every object is built from a class. Each class should be designed and programmed to accomplish one, and only one, thing. 26
  • 27. OO definitions  An instance is a specific object built from a specific class. It is assigned to a reference variable that is used to access all of the instance's properties and methods. When you make a new instance the process is called instantiation and is typically done using the new keyword. 27
  • 28. OO definitions    A class is like a recipe for chocolate cake. The recipe itself is not a cake. You can't eat the recipe (or at least wouldn't want to). If you correctly do what the recipe tells you to do (instantiate it) then you have an edible cake. That edible cake is an instance of the chocolate cake class. 28
  • 29. OO concepts    A class is like a recipe for chocolate cake. The recipe itself is not a cake. You can't eat the recipe (or at least wouldn't want to). If you correctly do what the recipe tells you to do (instantiate it) then you have an edible cake. That edible cake is an instance of the chocolate cake class. 29
  • 30. Your Migrate Module  Migration should be in a SEPARATE module So you can turn it off once you are done.  Isolate it if you are going to be doing ongoing date based updates.  30
  • 31. Migrate supports       Support multi-field or composite keys. Tracks the source id and it’s final destination id and you can access this information during your migration. Translate from the old key to the new key. Can do a roll back. Can re-do a migration and update those articles in place. Do “date” based ongoing migrations. 31
  • 32. Migration class Configure all of your pieces for the migration  Selects the source data and map it to the destination data.  32
  • 33. Migration class  prepareRow(), prepare(), complete() Allow you to manipulate the data or skip records  Update other rows while migrating data   Writes out the destination data. 33
  • 35. Source data    Source data can be in SQL, CSV, XML, JSON format Need to have definition of these files. I used the SQL format. 35
  • 36. Field Handlers   A field definition within Drupal is an array structure Converts simple string data into the Drupal array structure 36
  • 38. Destination   Migrate will write the Destination nodes for you (node, user, other supported entities, or SQL rows). Create one destination record for each source record 38
  • 39. Order is critical    Must migrate user accounts before you can migrate user profiles. Know you data Create a list of the sequence in which the data is to be converted. 39
  • 40. Migration Class    Everything is done in code You write a “base class” from which you then extend in your code. In this base class, you can define things about this migration. Everything you want to do is an extension of an existing migrate class. 40
  • 41. Migration Class    Inherit and extend these classes You have to write a small module to “extend” the classes. Documentation is provided in the form of code examples. beer.inc  wire.inc  41
  • 42. Multiple DB in D6  Database select from within current database: * $db_url = 'pgsql://username:password@localhost/databasename'; */ *// - das - $db_url = 'mysqli://root@localhost/mis_project'; $db_url['default'] = 'mysqli://root@localhost/mis_project'; $db_url['legacy'] = 'mysqli://root@localhost/open_atrium_legacy'; $db_prefix = '';  Database select from within current database: $query = db_select('users_legacy', 'ul'); 42
  • 43. Multiple DB in D7  Define the database Database::addConnectionInfo('jnn_xoops', 'default', array( 'driver' => 'mysql', 'database' => 'jnn_xoops', 'username' => 'root', 'password' => 'root', 'host' => 'localhost', 'prefix' => '', ));  Define the query $query = Database::getConnection('default', 'jnn_xoops') ->select('xoops_users', 'xu') ->fields('xu', array('uid', 'name', 'uname', 'email')); 43
  • 44. My Module   Structure of my migration module was placed in sites/all/modules/custom. My module name is: migrate_mc_oa migrate_mc_oa.info  migrate_mc_oa.install  migrate_mc_oa.module  migrate_mc_oa.inc  44
  • 45. My Module  Structure of my migration module migrate_mc_oa_user.inc  migrate_mc_oa_node_og.inc  migrate_mc_oa_book.inc  migrate_mc_oa_node_ct.inc  migrate_mc_oc_comment.inc  45
  • 47. Let’s see the code class McOaBasicMigration extends McOaMigration { public function __construct() { parent::__construct(); $this->description = t('Descriptions'); $this->dependencies = array('Other_Migration_Dependencies'); $this->map = new MigrateSQLMap(....)); $query=db_select('comments_legacy', 'cl'); or $query = Database::getConnection('default', 'legacy') ->select('comments', 'cl'); $this->source = new MigrateSourceSQL($query); $this->destination = new MigrateDestinationComment('comment_case_tracker_case'); $this->addFieldMapping('pid', 'pid'); $this->addFieldMapping('nid', 'nid') ->sourceMigration('McOaCaseCt'); // Unmapped destination fields $this->addUnmigratedDestinations(array('fname', 'lname')); 47
  • 48. Drush Migrate Cmds       https://drupal.org/node/1561820 drush migrate-import Article drush migrate-import Article --limit="100 items" drush migrate-import --all=User drush migrate-import –rollback –all drush migrate-import –update –group = [grp_name] 48