Newer
Older
Moshe Weitzman
committed
<?php
/**
* @file
* Set up the migration example module.
*/
Moshe Weitzman
committed
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'migrate_example') .
'/beer.install.inc';
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'migrate_example') .
'/wine.install.inc';
function migrate_example_schema() {
$schema = migrate_example_beer_schema();
$schema += migrate_example_wine_schema();
return $schema;
}
function migrate_example_install() {
migrate_example_wine_install();
// A simple format for testing migration of format
$example_format = array(
Moshe Weitzman
committed
'format' => 'migrate_example',
'name' => 'Migrate example format',
'weight' => 20,
'filters' => array(
// Escape all HTML.
'filter_html_escape' => array(
'weight' => 0,
'status' => 1,
),
),
);
$example_format = (object) $example_format;
filter_format_save($example_format);
}
function migrate_example_uninstall() {
migrate_example_wine_uninstall();
Moshe Weitzman
committed
if ($format = filter_format_load('migrate_example')) {
filter_format_disable($format);
}
function migrate_example_disable() {
migrate_example_beer_disable();
migrate_example_wine_disable();
}
/**
* Convert modificationdate datetime field to modificationdatetime int field.
*/
function migrate_example_update_7001() {
$ret = array();
db_add_field('migrate_example_beer_legacy_urls', 'modificationdatetime', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
)
);
$result = db_select('migrate_example_beer_legacy_urls', 'ms')
->fields('ms', array('machine_name', 'modificationdate'))
->execute();
foreach ($result as $row) {
$modificationdatetime = strtotime($row->modificationdate);
db_update('migrate_example_beer_legacy_urls')
->fields(array('modificationdatetime' => $modificationdatetime))
->condition('machine_name', $row->machineName)
->execute();
}
db_drop_field('migrate_example_beer_legacy_urls', 'modificationdate');
$ret[] = t('Converted modificationdate datetime field to modificationdatetime int field');
return $ret;
}
Mike Ryan
committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* Add image alt/title/description columns.
*/
function migrate_example_update_7002() {
$ret = array();
db_add_field('migrate_example_beer_node', 'image_alt', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'Image ALT',
)
);
db_add_field('migrate_example_beer_node', 'image_title', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'Image title',
)
);
db_add_field('migrate_example_beer_node', 'image_description', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'Image description',
)
);
db_update('migrate_example_beer_node')
->fields(array(
'image_alt' => 'Heinekin alt',
'image_title' => 'Heinekin title',
'image_description' => 'Heinekin description',
))
->condition('bid', 99999999)
->execute();
$ret[] = t('Added image_alt, image_title, and image_description fields.');
return $ret;
}