-
Notifications
You must be signed in to change notification settings - Fork 0
/
story.inc
45 lines (39 loc) · 1.3 KB
/
story.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
class StoryMigration extends Migration {
public function __construct() {
parent::__construct();
$this->description = t('Migration of old stories into article nodes');
/*
* Build up a query of the old stories
*/
$query = Database::getConnection('default', 'for_migration')
->select('stories', 'old_stories');
$query->fields('old_stories'); // this grabs all fields from "old_stories"
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationNode('article');
/*
* Add field mappings as Drupal object property and source field name
*/
$this->addFieldMapping('title', 'title');
$this->addFieldMapping('body', 'body');
$this->addFieldMapping('uid', 'author_id')
->sourceMigration('User')
->defaultValue(1);
$this->addFieldMapping('created', 'date_created');
$this->addFieldMapping('status', '')->defaultValue(1);
/*
* Add the SQL Mapping to store the key <-> key identifiers
*/
$this->map = new MigrateSQLMap(
$this->machineName,
array('id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'ID of source row',
)
),
MigrateDestinationNode::getKeySchema()
);
}
}