Migrate - new way site upgrade

254
-1

Published on

Рассмотрим сам фреймворк, определим основные юзкейсы использования, базовые требования для использования, а так же посмотрим на код на примере миграции Drupal 7 - Drupal 7. Думаю так же доклад будет интересен для всех, кто планирует использовать будущий релиз Drupal, ввиду того, что Migrate частично мигрировал в ядро и будет инструментом по умолчанию для апгрейда не только с 7 версии, но и с 6(возможно даже с 5!!!).

Published in: Internet, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
254
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Migrate - new way site upgrade

  1. 1. 25 -27 April, 2014 http://camp2014.drupal.dn.ua Migrate - new way site upgrade Kirill Roskoliy Email: roskoliy.kirill@gmail.com DO: https://drupal.org/user/325151 Trellon, LLC
  2. 2. WHAT IS THIS ALL ABOUT: 1. How it was and how it will be 2. Migrate structure 3. Use cases 4. Requirements 5. Examples 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  3. 3. How it was and how it will be •In place upgrade - Drupal 7.x =< •Migrate way 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  4. 4. In place upgrade This is standard upgrade path in Drupal 7 and previous. What does it mean? Lets take a closer look: 1. We need to stage current site 1. Code 2. DB 3. Files 4. Done some pre-upgrade configuration 2. Put in place upgraded code 1. Remove old one 2. Put new 3. Start update.php 4. Pray that everything will go well, no? - Go to #1 5. Profit 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  5. 5. Migrate way of upgrade 1.No direct pruduction site modifications 2.Build new version of your site 3.Migrate 4.Issues ? - Go to #2 5.Profit 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  6. 6. Migrate module architecture ● Migration ○ MigrateSource ○ MigrateDestination ○ MigrateMap ○ MigrateFieldMapping 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  7. 7. Use cases ● Major version upgrade ● Site structure redesign ● Migration from other CMS ● Migration from static HTML ● Initial data import 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  8. 8. Requerments Sources: ● DB access ● Files access 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  9. 9. Example: Content type migration 1 <?php class SomeArticlesMigration extends DrupalNode7Migration { public function __construct($arguments) { $files_path = $arguments['source_domain_root'] . '/sites/default/files'; $this->description = t('Import article nodes.'); // Pulling extra fields to source row. $this->sourceFields['field_tags'] = 'Tags for the article'; $this->sourceFields['field_image'] = 'Header Image'; $this->sourceFields['field_multi_images_upload'] = 'Multi images upload'; $this->sourceFields['field_article_comment_header'] = 'Comment Header'; $this->sourceFields['field_juicebox_gallery'] = 'Juicebox Gallery'; $this->sourceFields['field_embed_map'] = 'Embed Map'; $this->sourceFields['field_map_location'] = 'Map Location'; parent::__construct($arguments); 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  10. 10. Example: Content type migration 2 // Field mappings. // Field field_tags. $this->addFieldMapping('field_tags', 'field_tags'); $this->addFieldMapping('field_tags:source_type')->defaultValue('tid'); $this->addFieldMapping('field_tags:create_term')->defaultValue(TRUE); $this->addFieldMapping('field_tags:ignore_case')->defaultValue(TRUE); // Field field_image. $this->addFieldMapping('field_image', 'field_image'); $this->addFieldMapping('field_image:file_class')->defaultValue(‘SomeArticleImages’); $this->addFieldMapping('field_image:source_dir')->defaultValue($files_path . '/field/image/'); $this->addFieldMapping('field_image:destination_dir')->defaultValue('public://field/image/'); $this->addFieldMapping('field_image:file_replace')->defaultValue(FILE_EXISTS_REPLACE); $this->addFieldMapping('field_image:preserve_files')->defaultValue(FALSE); $this->addFieldMapping('field_image:alt', 'field_image:alt'); 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  11. 11. Example: Content type migration 3 // Field field_article_comment_header - simple text field. $this->addFieldMapping('field_article_comment_header', 'field_article_comment_header'); // Field field_embed_map - boolean field. $this->addFieldMapping('field_embed_map', 'field_embed_map'); // Field field_map_location - geofield. $this->addFieldMapping('field_map_location', 'field_map_location'); $this->addFieldMapping('field_map_location:lng', 'field_map_location:lng') ->callbacks('coconuts_migrate_map_location_lng');; } 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  12. 12. Example: Content type migration 4 /** * Limit selecting nodes only to those assigned to specified source domain. * @return QueryConditionInterface * Modified $query object. */ protected function query() { $query = parent::query(); $source_domain_id = (int) $this->arguments['source_domain_id']; $query->join('domain_access', 'da', 'da.nid = n.nid'); // Limit nodes to source domain and to those for ALL domains(gid == 0). $query->condition('da.gid', array(0, $source_domain_id)); return $query; } protected function preImport() { $some_dummy_code_here = TRUE; } } 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  13. 13. Example: Helper class to migrate images <?php class SomeArticleImages extends MigrateFileUri { public function __construct($arguments = array(), $default_file = NULL) { parent::__construct($arguments, $default_file); } public function processFile($value, $owner) { $filename = Database::getConnection('default', SOME_MIGRATE_CONNECTION_KEY) ->select('file_managed', 'f') ->fields('f', array('filename')) ->condition('fid', $value) ->execute() ->fetchField(); return parent::processFile($filename, $owner); } } 25 -27 April, 2014 http://camp2014.drupal.dn.ua/
  14. 14. THANK YOU! Questions? Kirill Roskoliy Email: roskoliy.kirill@gmail.com DO: https://drupal.org/user/325151 Trellon, LLC
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×