beer.install.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <?php
  2. /**
  3. * @file
  4. * Set up for the beer (basic) example.
  5. */
  6. function migrate_example_beer_schema() {
  7. $schema['migrate_example_beer_account'] = migrate_example_beer_schema_account();
  8. $schema['migrate_example_beer_node'] = migrate_example_beer_schema_node();
  9. $schema['migrate_example_beer_comment'] = migrate_example_beer_schema_comment();
  10. $schema['migrate_example_beer_topic'] = migrate_example_beer_schema_topic();
  11. $schema['migrate_example_beer_topic_node'] = migrate_example_beer_schema_topic_node();
  12. // These two tables are primarily for testing the table_copy plugin.
  13. // They do provide some guidance for uri redirection per uri_map_redirect.php
  14. $schema['migrate_example_beer_legacy_urls'] = migrate_example_beer_schema_legacy_urls();
  15. $schema['migrate_example_beer_copy_urls'] = migrate_example_beer_schema_legacy_urls();
  16. return $schema;
  17. }
  18. function migrate_example_beer_install() {
  19. migrate_example_beer_content_type();
  20. migrate_example_beer_tags();
  21. migrate_example_beer_image();
  22. migrate_example_beer_country();
  23. migrate_example_beer_gender();
  24. if (module_exists('node_reference')) {
  25. migrate_example_beer_favs();
  26. }
  27. // Populate our tables.
  28. migrate_example_beer_data_account();
  29. migrate_example_beer_data_node();
  30. migrate_example_beer_data_comment();
  31. migrate_example_beer_data_topic();
  32. migrate_example_beer_data_topic_node();
  33. migrate_example_beer_data_urls();
  34. }
  35. function migrate_example_beer_uninstall() {
  36. if ($vids = taxonomy_vocabulary_load_multiple(array(), array('machine_name' => 'migrate_example_beer_styles'))) {
  37. // Grab key of the first returned vocabulary.
  38. taxonomy_vocabulary_delete(key($vids));
  39. }
  40. migrate_example_beer_content_type_delete();
  41. }
  42. function migrate_example_beer_disable() {
  43. MigrateGroup::deregister('beer');
  44. }
  45. function migrate_example_beer_schema_node() {
  46. return array(
  47. 'description' => 'Beers of the world.',
  48. 'fields' => array(
  49. 'bid' => array(
  50. 'type' => 'serial',
  51. 'not null' => TRUE,
  52. 'description' => 'Beer ID.',
  53. ),
  54. 'name' => array(
  55. 'type' => 'varchar',
  56. 'length' => 255,
  57. 'not null' => TRUE,
  58. ),
  59. 'body' => array(
  60. 'type' => 'varchar',
  61. 'length' => 255,
  62. 'not null' => FALSE,
  63. 'description' => 'Full description of the beer.',
  64. ),
  65. 'excerpt' => array(
  66. 'type' => 'varchar',
  67. 'length' => 255,
  68. 'not null' => FALSE,
  69. 'description' => 'Abstract for this beer.',
  70. ),
  71. 'countries' => array(
  72. 'type' => 'varchar',
  73. 'length' => 255,
  74. 'not null' => FALSE,
  75. 'description' => 'Countries of origin. Multiple values, delimited by pipe',
  76. ),
  77. 'aid' => array(
  78. 'type' => 'int',
  79. 'not null' => FALSE,
  80. 'description' => 'Account Id of the author.',
  81. ),
  82. 'image' => array(
  83. 'type' => 'varchar',
  84. 'length' => 255,
  85. 'not null' => FALSE,
  86. 'description' => 'Image path',
  87. ),
  88. 'image_alt' => array(
  89. 'type' => 'varchar',
  90. 'length' => 255,
  91. 'not null' => FALSE,
  92. 'description' => 'Image ALT',
  93. ),
  94. 'image_title' => array(
  95. 'type' => 'varchar',
  96. 'length' => 255,
  97. 'not null' => FALSE,
  98. 'description' => 'Image title',
  99. ),
  100. 'image_description' => array(
  101. 'type' => 'varchar',
  102. 'length' => 255,
  103. 'not null' => FALSE,
  104. 'description' => 'Image description',
  105. ),
  106. ),
  107. 'primary key' => array('bid'),
  108. );
  109. }
  110. function migrate_example_beer_schema_topic() {
  111. return array(
  112. 'description' => 'Categories',
  113. 'fields' => array(
  114. 'style' => array(
  115. 'type' => 'varchar',
  116. 'length' => 255,
  117. 'not null' => TRUE,
  118. ),
  119. 'details' => array(
  120. 'type' => 'varchar',
  121. 'length' => 255,
  122. 'not null' => FALSE,
  123. ),
  124. 'style_parent' => array(
  125. 'type' => 'varchar',
  126. 'length' => 255,
  127. 'not null' => FALSE,
  128. 'description' => 'Parent topic, if any',
  129. ),
  130. 'region' => array(
  131. 'type' => 'varchar',
  132. 'length' => 255,
  133. 'not null' => FALSE,
  134. 'description' => 'Region first associated with this style',
  135. ),
  136. 'hoppiness' => array(
  137. 'type' => 'varchar',
  138. 'length' => 255,
  139. 'not null' => FALSE,
  140. 'description' => 'Relative hoppiness of the beer',
  141. ),
  142. ),
  143. 'primary key' => array('style'),
  144. );
  145. }
  146. function migrate_example_beer_schema_topic_node() {
  147. return array(
  148. 'description' => 'Beers topic pairs.',
  149. 'fields' => array(
  150. 'bid' => array(
  151. 'type' => 'int',
  152. 'not null' => TRUE,
  153. 'description' => 'Beer ID.',
  154. ),
  155. 'style' => array(
  156. 'type' => 'varchar',
  157. 'length' => 255,
  158. 'not null' => TRUE,
  159. 'description' => 'Topic name',
  160. ),
  161. ),
  162. 'primary key' => array('style', 'bid'),
  163. );
  164. }
  165. function migrate_example_beer_schema_comment() {
  166. return array(
  167. 'description' => 'Beers comments.',
  168. 'fields' => array(
  169. 'cid' => array(
  170. 'type' => 'serial',
  171. 'not null' => TRUE,
  172. 'description' => 'Comment ID.',
  173. ),
  174. 'bid' => array(
  175. 'type' => 'int',
  176. 'not null' => TRUE,
  177. 'description' => 'Beer ID that is being commented upon',
  178. ),
  179. 'cid_parent' => array(
  180. 'type' => 'int',
  181. 'not null' => FALSE,
  182. 'description' => 'Parent comment ID in case of comment replies.',
  183. ),
  184. 'subject' => array(
  185. 'type' => 'varchar',
  186. 'length' => 255,
  187. 'not null' => FALSE,
  188. 'description' => 'Comment subject',
  189. ),
  190. 'body' => array(
  191. 'type' => 'varchar',
  192. 'length' => 255,
  193. 'not null' => FALSE,
  194. 'description' => 'Comment body',
  195. ),
  196. 'name' => array(
  197. 'type' => 'varchar',
  198. 'length' => 255,
  199. 'not null' => FALSE,
  200. 'description' => 'Comment name (if anon)',
  201. ),
  202. 'mail' => array(
  203. 'type' => 'varchar',
  204. 'length' => 255,
  205. 'not null' => FALSE,
  206. 'description' => 'Comment email (if anon)',
  207. ),
  208. 'aid' => array(
  209. 'type' => 'int',
  210. 'not null' => FALSE,
  211. 'description' => 'Account ID (if any).',
  212. ),
  213. ),
  214. 'primary key' => array('cid'),
  215. );
  216. }
  217. function migrate_example_beer_schema_account() {
  218. return array(
  219. 'description' => 'Beers accounts.',
  220. 'fields' => array(
  221. 'aid' => array(
  222. 'type' => 'serial',
  223. //'not null' => TRUE,
  224. 'description' => 'Account ID',
  225. ),
  226. 'status' => array(
  227. 'type' => 'int',
  228. 'not null' => TRUE,
  229. 'description' => 'Blocked_Allowed',
  230. ),
  231. 'posted' => array(
  232. 'type' => 'varchar',
  233. 'length' => 255,
  234. 'not null' => TRUE,
  235. 'description' => 'Registration date',
  236. ),
  237. 'name' => array(
  238. 'type' => 'varchar',
  239. 'length' => 255,
  240. 'not null' => FALSE,
  241. 'description' => 'Account name (for login)',
  242. ),
  243. 'nickname' => array(
  244. 'type' => 'varchar',
  245. 'length' => 255,
  246. 'not null' => FALSE,
  247. 'description' => 'Account name (for display)',
  248. ),
  249. 'password' => array(
  250. 'type' => 'varchar',
  251. 'length' => 255,
  252. 'not null' => FALSE,
  253. 'description' => 'Account password (raw)',
  254. ),
  255. 'mail' => array(
  256. 'type' => 'varchar',
  257. 'length' => 255,
  258. 'not null' => FALSE,
  259. 'description' => 'Account email',
  260. ),
  261. 'sex' => array(
  262. 'type' => 'int',
  263. 'not null' => FALSE,
  264. 'description' => 'Gender',
  265. ),
  266. 'beers' => array(
  267. 'type' => 'varchar',
  268. 'length' => 255,
  269. 'not null' => FALSE,
  270. 'description' => 'Favorite Beers',
  271. ),
  272. ),
  273. 'primary key' => array('aid'),
  274. );
  275. }
  276. function migrate_example_beer_schema_legacy_urls() {
  277. return array(
  278. 'description' => 'Stores legacy paths and destination ids for redirection.',
  279. 'fields' => array(
  280. 'id' => array(
  281. 'type' => 'int',
  282. 'not null' => TRUE,
  283. 'description' => 'Primary Key: ID.',
  284. ),
  285. 'migration_name' => array(
  286. 'type' => 'varchar',
  287. 'length' => 50,
  288. 'not null' => TRUE,
  289. 'default' => '',
  290. ),
  291. 'source_id' => array(
  292. 'type' => 'int',
  293. 'not null' => FALSE,
  294. ),
  295. 'source_uri' => array(
  296. 'type' => 'varchar',
  297. 'length' => 500,
  298. 'not null' => FALSE,
  299. ),
  300. 'modificationdatetime' => array(
  301. 'type' => 'int',
  302. 'unsigned' => TRUE,
  303. 'not null' => TRUE,
  304. ),
  305. ),
  306. 'primary key' => array('ID'),
  307. 'indexes' => array(
  308. 'source_uri' => array(array('source_uri', 255)),
  309. ),
  310. );
  311. }
  312. function migrate_example_beer_content_type() {
  313. // This code based on from standard.profile.
  314. // Insert default user-defined node types into the database.
  315. $types = array(
  316. array(
  317. 'type' => 'migrate_example_beer',
  318. 'name' => st('Beer'),
  319. 'base' => 'node_content',
  320. 'description' => st("Beer is what we drink."),
  321. 'custom' => 1,
  322. 'modified' => 1,
  323. 'locked' => 1,
  324. ),
  325. );
  326. foreach ($types as $type) {
  327. $type = node_type_set_defaults($type);
  328. node_type_save($type);
  329. node_add_body_field($type);
  330. }
  331. }
  332. function migrate_example_beer_tags() {
  333. // Create a vocabulary named "Migrate Example Beer Styles", enabled for the 'migrate_example_beer' content type.
  334. $description = st('Use tags to group beers on similar topics into categories.');
  335. $help = st('Enter a comma-separated list of words to describe your content.');
  336. $vocabulary = (object) array(
  337. 'name' => 'Migrate Example Beer Styles',
  338. 'description' => $description,
  339. 'machine_name' => 'migrate_example_beer_styles',
  340. 'help' => $help,
  341. );
  342. taxonomy_vocabulary_save($vocabulary);
  343. if (!field_info_field('migrate_example_beer_styles')) {
  344. $field = array(
  345. 'field_name' => $vocabulary->machine_name,
  346. 'type' => 'taxonomy_term_reference',
  347. // Set cardinality to unlimited for tagging.
  348. 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  349. 'settings' => array(
  350. 'allowed_values' => array(
  351. array(
  352. 'vocabulary' => $vocabulary->machine_name,
  353. 'vid' => $vocabulary->vid,
  354. 'parent' => 0,
  355. ),
  356. ),
  357. ),
  358. );
  359. field_create_field($field);
  360. }
  361. if (!field_info_instance('node', 'migrate_example_beer_styles', 'migrate_example_beer')) {
  362. $instance = array(
  363. 'field_name' => $vocabulary->machine_name,
  364. 'entity_type' => 'node',
  365. 'label' => $vocabulary->name,
  366. 'bundle' => 'migrate_example_beer',
  367. 'description' => $vocabulary->help,
  368. 'widget' => array(
  369. 'type' => 'taxonomy_autocomplete',
  370. ),
  371. );
  372. field_create_instance($instance);
  373. }
  374. }
  375. // Create an image field named "Migrate Example Image", enabled for the 'Beer' content type.
  376. function migrate_example_beer_image() {
  377. if (!field_info_field('field_migrate_example_image')) {
  378. $field = array(
  379. 'field_name' => 'field_migrate_example_image',
  380. 'type' => 'image',
  381. 'cardinality' => 1,
  382. 'translatable' => TRUE,
  383. 'indexes' => array('fid' => array('fid')),
  384. 'settings' => array(
  385. 'uri_scheme' => 'public',
  386. 'default_image' => FALSE,
  387. ),
  388. );
  389. field_create_field($field);
  390. }
  391. if (!field_info_instance('node', 'field_migrate_example_image', 'migrate_example_beer')) {
  392. $instance = array(
  393. 'field_name' => 'field_migrate_example_image',
  394. 'entity_type' => 'node',
  395. 'label' => 'Image',
  396. 'bundle' => 'migrate_example_beer',
  397. 'description' => 'Upload an image to go with this beer.',
  398. 'settings' => array(
  399. 'file_directory' => 'field/migrate_example/image',
  400. 'file_extensions' => 'png gif jpg jpeg',
  401. 'max_filesize' => '',
  402. 'max_resolution' => '',
  403. 'min_resolution' => '',
  404. 'alt_field' => TRUE,
  405. 'title_field' => '',
  406. ),
  407. 'widget' => array(
  408. 'type' => 'image_image',
  409. 'settings' => array(
  410. 'progress_indicator' => 'throbber',
  411. 'preview_image_style' => 'thumbnail',
  412. ),
  413. 'weight' => -1,
  414. ),
  415. 'display' => array(
  416. 'full' => array(
  417. 'label' => 'hidden',
  418. 'type' => 'image__large',
  419. 'settings' => array(),
  420. 'weight' => -1,
  421. ),
  422. 'teaser' => array(
  423. 'label' => 'hidden',
  424. 'type' => 'image_link_content__medium',
  425. 'settings' => array(),
  426. 'weight' => -1,
  427. ),
  428. 'rss' => array(
  429. 'label' => 'hidden',
  430. 'type' => 'image__large',
  431. 'settings' => array(),
  432. 'weight' => -1,
  433. ),
  434. 'search_index' => array(
  435. 'label' => 'hidden',
  436. 'type' => 'image__large',
  437. 'settings' => array(),
  438. 'weight' => -1,
  439. ),
  440. 'search_results' => array(
  441. 'label' => 'hidden',
  442. 'type' => 'image__large',
  443. 'settings' => array(),
  444. 'weight' => -1,
  445. ),
  446. ),
  447. );
  448. field_create_instance($instance);
  449. }
  450. }
  451. function migrate_example_beer_favs() {
  452. if (!field_info_field('field_migrate_example_favbeers')) {
  453. $field = array(
  454. 'field_name' => 'field_migrate_example_favbeers',
  455. 'type' => 'node_reference',
  456. 'cardinality' => -1,
  457. 'settings' => array(
  458. 'referenceable_types' => array('migrate_example_beer'),
  459. ),
  460. );
  461. field_create_field($field);
  462. }
  463. if (!field_info_instance('user', 'field_migrate_example_favbeers', 'user')) {
  464. $instance = array(
  465. 'field_name' => 'field_migrate_example_favbeers',
  466. 'entity_type' => 'user',
  467. 'label' => 'Favorite Beers',
  468. 'bundle' => 'user',
  469. 'widget' => array(
  470. 'type' => 'node_reference_autocomplete',
  471. ),
  472. );
  473. field_create_instance($instance);
  474. }
  475. }
  476. // Create Gender list field on User entity.
  477. function migrate_example_beer_gender() {
  478. if (!field_info_field('field_migrate_example_gender')) {
  479. $field = array(
  480. 'field_name' => 'field_migrate_example_gender',
  481. 'type' => 'list_integer',
  482. 'settings' => array(
  483. 'allowed_values' =>
  484. "0|Male\n" .
  485. "1|Female\n",
  486. ),
  487. );
  488. field_create_field($field);
  489. }
  490. if (!field_info_instance('user', 'field_migrate_example_gender', 'user')) {
  491. $instance = array(
  492. 'field_name' => 'field_migrate_example_gender',
  493. 'entity_type' => 'user',
  494. 'label' => 'Gender',
  495. 'bundle' => 'user',
  496. 'widget' => array(
  497. 'type' => 'options_select',
  498. ),
  499. );
  500. field_create_instance($instance);
  501. }
  502. }
  503. // Create a text field named "Countries", enabled for the 'Beer' content type.
  504. function migrate_example_beer_country() {
  505. if (!field_info_field('field_migrate_example_country')) {
  506. $field = array(
  507. 'field_name' => 'field_migrate_example_country',
  508. 'type' => 'text',
  509. 'cardinality' => -1,
  510. );
  511. field_create_field($field);
  512. }
  513. if (!field_info_instance('node', 'field_migrate_example_country', 'migrate_example_beer')) {
  514. $instance = array(
  515. 'field_name' => 'field_migrate_example_country',
  516. 'entity_type' => 'node',
  517. 'label' => 'Countries',
  518. 'bundle' => 'migrate_example_beer',
  519. 'description' => 'Beer country.',
  520. 'widget' => array(
  521. 'type' => 'text_textfield',
  522. ),
  523. );
  524. field_create_instance($instance);
  525. }
  526. }
  527. function migrate_example_beer_content_type_delete() {
  528. $bundle = 'migrate_example_beer';
  529. $field_names = array('migrate_example_beer_styles', 'field_migrate_example_image', 'field_migrate_example_country');
  530. foreach ($field_names as $field_name) {
  531. $instance = field_info_instance('node', $field_name, $bundle);
  532. field_delete_instance($instance);
  533. field_delete_field($field_name);
  534. }
  535. node_type_delete($bundle);
  536. $bundle = 'user';
  537. $field_names = array('field_migrate_example_gender');
  538. if (module_exists('node_reference')) {
  539. $field_names[] = 'field_migrate_example_favbeers';
  540. }
  541. foreach ($field_names as $field_name) {
  542. $instance = field_info_instance('user', $field_name, $bundle);
  543. field_delete_instance($instance);
  544. field_delete_field($field_name);
  545. }
  546. }
  547. function migrate_example_beer_data_node() {
  548. $fields = array('bid', 'name', 'body', 'excerpt', 'countries', 'aid', 'image',
  549. 'image_alt', 'image_title', 'image_description');
  550. $query = db_insert('migrate_example_beer_node')
  551. ->fields($fields);
  552. // Use high bid numbers to avoid overwriting an existing node id.
  553. $data = array(
  554. array(99999999, 'Heineken', 'Blab Blah Blah Green', 'Green', 'Netherlands|Belgium', 0, 'heineken.jpg', 'Heinekin alt', 'Heinekin title', 'Heinekin description'), // comes with migrate_example project.
  555. array(99999998, 'Miller Lite', 'We love Miller Brewing', 'Tasteless', 'USA|Canada', 1, NULL, NULL, NULL, NULL),
  556. array(99999997, 'Boddington', 'English occassionally get something right', 'A treat', 'United Kingdom', 1, NULL, NULL, NULL, NULL),
  557. );
  558. foreach ($data as $row) {
  559. $query->values(array_combine($fields, $row));
  560. }
  561. $query->execute();
  562. }
  563. // Note that alice has duplicate username. Exercies dedupe() method.
  564. // @TODO duplicate email also.
  565. function migrate_example_beer_data_account() {
  566. $fields = array('status', 'posted', 'name', 'nickname', 'password', 'mail', 'sex', 'beers');
  567. $query = db_insert('migrate_example_beer_account')
  568. ->fields($fields);
  569. $data = array(
  570. array(1, '2010-03-30 10:31:05', 'alice', 'alice hot pants', 'alicepass', 'alice@example.com', '1', '99999999|99999998|99999997'),
  571. array(1, '2010-04-04 10:31:05', 'alice', 'alice dupe pants', 'alicepass', 'alice2@example.com', '1', '99999999|99999998|99999997'),
  572. array(0, '2007-03-15 10:31:05', 'bob', 'rebob', 'bobpass', 'bob@example.com', '1', '99999999|99999997'),
  573. array(1, '2004-02-29 10:31:05', 'charlie', 'charlie chocolate', 'mykids', 'charlie@example.com', '0', '99999999|99999998'),
  574. );
  575. foreach ($data as $row) {
  576. $query->values(array_combine($fields, $row));
  577. }
  578. $query->execute();
  579. }
  580. function migrate_example_beer_data_comment() {
  581. $fields = array('bid', 'cid_parent', 'subject', 'body', 'name', 'mail', 'aid');
  582. $query = db_insert('migrate_example_beer_comment')
  583. ->fields($fields);
  584. $data = array(
  585. array(99999998, NULL, 'im first', 'hot body', 'alice', 'alice@example.com', 0),
  586. array(99999998, NULL, 'im second', 'hot body', 'alice', 'alice@example.com', 0),
  587. array(99999999, NULL, 'im parent', 'hot body', 'alice', 'alice@example.com', 0),
  588. array(99999999, 1, 'im child', 'cold body', 'bob', NULL, 1),
  589. array(99999999, 2, 'im grandchild', 'bitter body', 'charlie@example.com', NULL, 1),
  590. );
  591. foreach ($data as $row) {
  592. $query->values(array_combine($fields, $row));
  593. }
  594. $query->execute();
  595. }
  596. function migrate_example_beer_data_topic() {
  597. $fields = array('style', 'details', 'style_parent', 'region', 'hoppiness');
  598. $query = db_insert('migrate_example_beer_topic')
  599. ->fields($fields);
  600. $data = array(
  601. array('ale', 'traditional', NULL, 'Medieval British Isles', 'Medium'),
  602. array('red ale', 'colorful', 'ale', NULL, NULL),
  603. array('pilsner', 'refreshing', NULL, 'Pilsen, Bohemia (now Czech Republic)', 'Low'),
  604. );
  605. foreach ($data as $row) {
  606. $query->values(array_combine($fields, $row));
  607. }
  608. $query->execute();
  609. }
  610. function migrate_example_beer_data_topic_node() {
  611. $fields = array('bid', 'style');
  612. $query = db_insert('migrate_example_beer_topic_node')
  613. ->fields($fields);
  614. $data = array(
  615. array(99999999, 'pilsner'),
  616. array(99999999, 'red ale'),
  617. array(99999998, 'red ale'),
  618. );
  619. foreach ($data as $row) {
  620. $query->values(array_combine($fields, $row));
  621. }
  622. $query->execute();
  623. }
  624. function migrate_example_beer_data_urls() {
  625. $fields = array('id', 'migration_name', 'source_id', 'source_uri', 'modificationdatetime');
  626. $query = db_insert('migrate_example_beer_legacy_urls')
  627. ->fields($fields);
  628. $data = array(
  629. array(1, 'BeerNode', 99999997, 'the_boddington/main', strtotime('2010-04-12 08:32:06')),
  630. array(2, 'BeerNode', 99999998, 'Miller Lite taste', strtotime('2010-04-12 08:32:05')),
  631. array(3, 'BeerNode', 99999999, 'green wonder', strtotime('2010-04-12 08:32:03')),
  632. );
  633. foreach ($data as $row) {
  634. $query->values(array_combine($fields, $row));
  635. }
  636. $query->execute();
  637. }