beer.install.inc 20 KB

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