backup_migrate.install 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <?php
  2. /**
  3. * @file
  4. * Install hooks for Backup and Migrate.
  5. */
  6. /**
  7. * Implementation of hook_requirements().
  8. */
  9. function backup_migrate_requirements($phase) {
  10. $requirements = array();
  11. return $requirements;
  12. }
  13. /**
  14. * Implementation of hook_schema().
  15. */
  16. function backup_migrate_schema() {
  17. $schema['backup_migrate_profiles'] = array(
  18. 'export' => array(
  19. 'key' => 'machine_name',
  20. 'key name' => 'Profile ID',
  21. 'admin_title' => 'name',
  22. 'primary key' => 'profile_id',
  23. 'identifier' => 'item', // Exports will be defined as $preset
  24. 'default hook' => 'exportables_backup_migrate_profiles', // Function hook name.
  25. 'api' => array(
  26. 'owner' => 'backup_migrate',
  27. 'api' => 'backup_migrate_exportables', // Base name for api include files.
  28. 'minimum_version' => 1,
  29. 'current_version' => 1,
  30. ),
  31. ),
  32. 'fields' => array(
  33. 'profile_id' => array(
  34. 'type' => 'serial',
  35. 'unsigned' => TRUE,
  36. 'not null' => TRUE,
  37. 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
  38. 'no export' => TRUE, // Do not export database-only keys.
  39. ),
  40. 'machine_name' => array(
  41. 'type' => 'varchar',
  42. 'length' => 255,
  43. 'not null' => TRUE,
  44. 'default' => '0',
  45. 'description' => 'The primary identifier for a profile.',
  46. ),
  47. 'name' => array(
  48. 'description' => 'The name of the profile.',
  49. 'type' => 'varchar',
  50. 'length' => 255,
  51. 'not null' => TRUE
  52. ),
  53. 'filename' => array(
  54. 'description' => 'The name of the profile.',
  55. 'type' => 'varchar',
  56. 'length' => 255,
  57. 'not null' => TRUE
  58. ),
  59. 'append_timestamp' => array(
  60. 'description' => 'Append a timestamp to the filename.',
  61. 'type' => 'int',
  62. 'size' => 'tiny',
  63. 'unsigned' => TRUE,
  64. 'not null' => TRUE,
  65. 'default' => 0
  66. ),
  67. 'timestamp_format' => array(
  68. 'description' => 'The format of the timestamp.',
  69. 'type' => 'varchar',
  70. 'length' => 14,
  71. 'not null' => TRUE
  72. ),
  73. 'filters' => array(
  74. 'description' => 'The filter settings for the profile.',
  75. 'type' => 'text',
  76. 'not null' => TRUE,
  77. 'serialize' => TRUE,
  78. 'serialized default' => 'a:0:{}',
  79. ),
  80. ),
  81. 'primary key' => array('profile_id'),
  82. );
  83. $schema['backup_migrate_destinations'] = array(
  84. 'export' => array(
  85. 'key' => 'machine_name',
  86. 'key name' => 'Destination ID',
  87. 'admin_title' => 'name',
  88. 'primary key' => 'destination_id',
  89. 'identifier' => 'item', // Exports will be defined as $preset
  90. 'default hook' => 'exportables_backup_migrate_destinations', // Function hook name.
  91. 'api' => array(
  92. 'owner' => 'backup_migrate',
  93. 'api' => 'backup_migrate_exportables', // Base name for api include files.
  94. 'minimum_version' => 1,
  95. 'current_version' => 1,
  96. ),
  97. ),
  98. 'fields' => array(
  99. 'destination_id' => array(
  100. 'type' => 'serial',
  101. 'unsigned' => TRUE,
  102. 'not null' => TRUE,
  103. 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
  104. 'no export' => TRUE, // Do not export database-only keys.
  105. ),
  106. 'machine_name' => array(
  107. 'type' => 'varchar',
  108. 'length' => 255,
  109. 'not null' => TRUE,
  110. 'default' => '0',
  111. 'description' => 'The primary identifier for a destination.',
  112. ),
  113. 'name' => array(
  114. 'description' => 'The name of the destination.',
  115. 'type' => 'varchar',
  116. 'length' => 255,
  117. 'not null' => TRUE
  118. ),
  119. 'subtype' => array(
  120. 'description' => 'The type of the destination.',
  121. 'type' => 'varchar',
  122. 'length' => 32,
  123. 'not null' => TRUE
  124. ),
  125. 'location' => array(
  126. 'description' => 'The the location string of the destination.',
  127. 'type' => 'text',
  128. 'not null' => TRUE
  129. ),
  130. 'settings' => array(
  131. 'description' => 'Other settings for the destination.',
  132. 'type' => 'text',
  133. 'not null' => TRUE,
  134. 'serialize' => TRUE,
  135. 'serialized default' => 'a:0:{}',
  136. ),
  137. ),
  138. 'primary key' => array('destination_id'),
  139. );
  140. $schema['backup_migrate_sources'] = array(
  141. 'export' => array(
  142. 'key' => 'machine_name',
  143. 'key name' => 'Source ID',
  144. 'admin_title' => 'name',
  145. 'primary key' => 'source_id',
  146. 'identifier' => 'item', // Exports will be defined as $preset
  147. 'default hook' => 'exportables_backup_migrate_sources', // Function hook name.
  148. 'api' => array(
  149. 'owner' => 'backup_migrate',
  150. 'api' => 'backup_migrate_exportables', // Base name for api include files.
  151. 'minimum_version' => 1,
  152. 'current_version' => 1,
  153. ),
  154. ),
  155. 'fields' => array(
  156. 'source_id' => array(
  157. 'type' => 'serial',
  158. 'unsigned' => TRUE,
  159. 'not null' => TRUE,
  160. 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
  161. 'no export' => TRUE, // Do not export database-only keys.
  162. ),
  163. 'machine_name' => array(
  164. 'type' => 'varchar',
  165. 'length' => 32,
  166. 'not null' => TRUE,
  167. 'default' => '0',
  168. 'description' => 'The primary identifier for a source.',
  169. ),
  170. 'name' => array(
  171. 'description' => 'The name of the source.',
  172. 'type' => 'varchar',
  173. 'length' => 255,
  174. 'not null' => TRUE
  175. ),
  176. 'subtype' => array(
  177. 'description' => 'The type of the source.',
  178. 'type' => 'varchar',
  179. 'length' => 32,
  180. 'not null' => TRUE
  181. ),
  182. 'location' => array(
  183. 'description' => 'The the location string of the source.',
  184. 'type' => 'text',
  185. 'not null' => TRUE
  186. ),
  187. 'settings' => array(
  188. 'description' => 'Other settings for the source.',
  189. 'type' => 'text',
  190. 'not null' => TRUE,
  191. 'serialize' => TRUE,
  192. 'serialized default' => 'a:0:{}',
  193. ),
  194. ),
  195. 'primary key' => array('source_id'),
  196. );
  197. $schema['backup_migrate_schedules'] = array(
  198. 'export' => array(
  199. 'key' => 'machine_name',
  200. 'key name' => 'Source ID',
  201. 'admin_title' => 'name',
  202. 'primary key' => 'schedule_id',
  203. 'identifier' => 'item', // Exports will be defined as $preset
  204. 'default hook' => 'exportables_backup_migrate_schedules', // Function hook name.
  205. 'api' => array(
  206. 'owner' => 'backup_migrate',
  207. 'api' => 'backup_migrate_exportables', // Base name for api include files.
  208. 'minimum_version' => 1,
  209. 'current_version' => 1,
  210. ),
  211. ),
  212. 'fields' => array(
  213. 'schedule_id' => array(
  214. 'type' => 'serial',
  215. 'unsigned' => TRUE,
  216. 'not null' => TRUE,
  217. 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
  218. 'no export' => TRUE, // Do not export database-only keys.
  219. ),
  220. 'machine_name' => array(
  221. 'type' => 'varchar',
  222. 'length' => 255,
  223. 'not null' => TRUE,
  224. 'default' => '0',
  225. 'description' => 'The primary identifier for a profile.',
  226. ),
  227. 'name' => array(
  228. 'description' => 'The name of the profile.',
  229. 'type' => 'varchar',
  230. 'length' => 255,
  231. 'not null' => TRUE
  232. ),
  233. 'source_id' => array(
  234. 'description' => 'The {backup_migrate_destination}.destination_id of the source to backup from.',
  235. 'type' => 'varchar',
  236. 'length' => 255,
  237. 'default' => 'db',
  238. 'not null' => TRUE
  239. ),
  240. 'destination_id' => array(
  241. 'type' => 'varchar',
  242. 'length' => 255,
  243. 'not null' => TRUE,
  244. 'default' => '0',
  245. 'description' => 'The {backup_migrate_destination}.destination_id of the destination to back up to.',
  246. ),
  247. 'copy_destination_id' => array(
  248. 'type' => 'varchar',
  249. 'length' => 32,
  250. 'not null' => TRUE,
  251. 'default' => '0',
  252. 'description' => 'A second {backup_migrate_destination}.destination_id of the destination to copy the backup to.',
  253. ),
  254. 'profile_id' => array(
  255. 'type' => 'varchar',
  256. 'length' => 255,
  257. 'not null' => TRUE,
  258. 'default' => '0',
  259. 'description' => 'The primary identifier for a profile.',
  260. ),
  261. 'keep' => array(
  262. 'type' => 'int',
  263. 'not null' => TRUE,
  264. 'default' => 0,
  265. 'description' => 'The number of backups to keep.',
  266. ),
  267. 'period' => array(
  268. 'type' => 'int',
  269. 'not null' => TRUE,
  270. 'default' => 0,
  271. 'description' => 'The number of seconds between backups.',
  272. ),
  273. 'enabled' => array(
  274. 'description' => 'Whether the schedule is enabled.',
  275. 'type' => 'int',
  276. 'size' => 'tiny',
  277. 'unsigned' => TRUE,
  278. 'not null' => TRUE,
  279. 'default' => 0
  280. ),
  281. 'cron' => array(
  282. 'description' => 'Whether the schedule should be run during cron.',
  283. 'type' => 'varchar',
  284. 'length' => 32,
  285. 'not null' => TRUE,
  286. 'default' => 'builtin',
  287. ),
  288. 'cron_schedule' => array(
  289. 'description' => 'The cron schedule to run on.',
  290. 'type' => 'varchar',
  291. 'length' => 255,
  292. 'not null' => TRUE,
  293. 'default' => '0 4 * * *',
  294. ),
  295. ),
  296. 'primary key' => array('schedule_id'),
  297. );
  298. return $schema;
  299. }
  300. /**
  301. * Implementation of hook_install().
  302. */
  303. function backup_migrate_install() {
  304. }
  305. /**
  306. * Remove variables on uninstall.
  307. */
  308. function backup_migrate_uninstall() {
  309. db_query("DELETE FROM {variable} WHERE name LIKE 'backup_migrate_%'");
  310. db_query("DELETE FROM {variable} WHERE name LIKE 'nodesquirrel_%'");
  311. cache_clear_all('variables', 'cache');
  312. }
  313. /**
  314. * Update from 1.x to 2.x.
  315. */
  316. function backup_migrate_update_2000() {
  317. _backup_migrate_setup_database_defaults();
  318. return array();
  319. }
  320. /**
  321. * Adding filter field for dev release of 2009-01-28
  322. */
  323. function backup_migrate_update_2001() {
  324. $ret = array();
  325. $schema = drupal_get_schema_unprocessed('backup_migrate', 'backup_migrate_profiles');
  326. // Add the filters field to the db.
  327. if (!db_field_exists('backup_migrate_profiles', 'filters')) {
  328. db_add_field('backup_migrate_profiles', 'filters', array('description' => t('The filter settings for the profile.'),'type' => 'text', 'not null' => TRUE));
  329. }
  330. // Add the source field
  331. if (!db_field_exists('backup_migrate_profiles', 'source_id')) {
  332. db_add_field('backup_migrate_profiles', 'source_id', array('description' => t('The {backup_migrate_destination}.destination_id of the source to backup from.'), 'type' => 'varchar', 'length' => 255, 'default' => 'db', 'not null' => TRUE));
  333. }
  334. // Remove the compression field.
  335. if (db_field_exists('backup_migrate_profiles', 'compression')) {
  336. db_drop_field('backup_migrate_profiles', 'compression');
  337. }
  338. return $ret;
  339. }
  340. /**
  341. * Clearing the cache because there was a menu structure change in the dev of 2009-05-31
  342. */
  343. function backup_migrate_update_2002() {
  344. // Cache should clear automatically. Nothing to do here.
  345. return array();
  346. }
  347. /**
  348. * Allowing non-int profile ids in schedules 2009-05-31
  349. */
  350. function backup_migrate_update_2003() {
  351. $ret = array();
  352. $spec = array(
  353. 'type' => 'varchar',
  354. 'length' => 255,
  355. 'not null' => TRUE,
  356. 'default' => '0',
  357. 'description' => 'The primary identifier for a profile.',
  358. );
  359. db_change_field('backup_migrate_schedules', 'profile_id', 'profile_id', $spec);
  360. return $ret;
  361. }
  362. /**
  363. * Allowing non-int profile ids 2009-07-01
  364. */
  365. function backup_migrate_update_2004() {
  366. $ret = array();
  367. $spec = array(
  368. 'type' => 'varchar',
  369. 'length' => 255,
  370. 'not null' => TRUE,
  371. 'default' => '0',
  372. );
  373. $spec['description'] = 'The primary identifier for a destination.';
  374. db_change_field('backup_migrate_destinations', 'destination_id', 'destination_id', $spec);
  375. $spec['description'] = 'The primary identifier for a profile.';
  376. db_change_field('backup_migrate_profiles', 'profile_id', 'profile_id', $spec);
  377. $spec['description'] = 'The primary identifier for a schedule.';
  378. db_change_field('backup_migrate_schedules', 'schedule_id', 'schedule_id', $spec);
  379. // Drop the user/pass fields as they weren't being used.
  380. if (db_field_exists('backup_migrate_destinations', 'username')) {
  381. db_drop_field('backup_migrate_destinations', 'username');
  382. }
  383. if (db_field_exists('backup_migrate_destinations', 'password')) {
  384. db_drop_field('backup_migrate_destinations', 'password');
  385. }
  386. return $ret;
  387. }
  388. /**
  389. * Change the default database id to something friendlier 2009-08-08
  390. */
  391. function backup_migrate_update_2005() {
  392. require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/crud.inc';
  393. require_once './'. drupal_get_path('module', 'backup_migrate') .'/includes/profiles.inc';
  394. $ret = array();
  395. // Change the destination ids of the defined database sources mostly to make using them with drush friendlier.
  396. // Change the db_url:default id to simply 'db'
  397. $ret[] = db_query("UPDATE {backup_migrate_profiles} SET source_id = 'db' WHERE source_id = 'db_url:default'");
  398. $ret[] = db_query("UPDATE {backup_migrate_schedules} SET destination_id = 'db' WHERE destination_id = 'db_url:default'");
  399. // Change the defined db keys from db_url:key to db:key.
  400. $ret[] = db_query("UPDATE {backup_migrate_profiles} SET source_id = REPLACE(source_id, 'db_url:', 'db:')");
  401. $ret[] = db_query("UPDATE {backup_migrate_schedules} SET destination_id = REPLACE(destination_id, 'db_url:', 'db:')");
  402. // Add the source field to the schedule
  403. if (!db_field_exists('backup_migrate_schedules', 'source_id')) {
  404. db_add_field('backup_migrate_schedules', 'source_id', array('description' => t('The db source to backup from.'), 'type' => 'varchar', 'length' => 255, 'default' => 'db', 'not null' => TRUE));
  405. }
  406. // Copy source data from profiles to schedules.
  407. $result = db_query('SELECT p.source_id, s.schedule_id FROM {backup_migrate_schedules} s LEFT JOIN {backup_migrate_profiles} p ON s.profile_id = p.profile_id', array(), array('fetch' => PDO::FETCH_ASSOC));
  408. foreach ($result as $schedule) {
  409. if (!$schedule['source_id']) {
  410. $schedule['source_id'] = 'db';
  411. }
  412. $ret[] = db_query("UPDATE {backup_migrate_schedules} SET source_id = '". $schedule['source_id'] ."' WHERE schedule_id = '". $schedule['profile_id'] ."'");
  413. }
  414. if (db_field_exists('backup_migrate_profiles', 'source_id')) {
  415. db_drop_field('backup_migrate_profiles', 'source_id');
  416. }
  417. // Copy the no-data and exclude tables settings into the 'filter' field.
  418. $result = db_query('SELECT * FROM {backup_migrate_profiles}', array(), array('fetch' => PDO::FETCH_ASSOC));
  419. foreach ($result as $item) {
  420. if (isset($item['nodata_tables']) && isset($item['exclude_tables'])) {
  421. $profile = backup_migrate_get_profile($item['profile_id']);
  422. $profile->filters['nodata_tables'] = unserialize($item['nodata_tables']);
  423. $profile->filters['exclude_tables'] = unserialize($item['exclude_tables']);
  424. $profile->save();
  425. }
  426. }
  427. if (db_field_exists('backup_migrate_profiles', 'nodata_tables')) {
  428. db_drop_field('backup_migrate_profiles', 'nodata_tables');
  429. }
  430. if (db_field_exists('backup_migrate_profiles', 'exclude_tables')) {
  431. db_drop_field('backup_migrate_profiles', 'exclude_tables');
  432. }
  433. return $ret;
  434. }
  435. /**
  436. * Move the backup and migrate directory to the private directory.
  437. */
  438. function backup_migrate_update_7200() {
  439. $from = 'public://backup_migrate';
  440. $to = 'private://backup_migrate';
  441. if (drupal_realpath($from) && !drupal_realpath($to)) {
  442. if (!rename($from, $to)) {
  443. drupal_set_message(t('Unable to move the backups directory to your private folder, please check file permissions and move the directory %from to %to', array('%from' => drupal_realpath($from), '%to' => drupal_realpath($to))), 'warning');
  444. }
  445. }
  446. }
  447. /**
  448. * Change the filename field to support 255 characters.
  449. */
  450. function backup_migrate_update_7202() {
  451. $ret = array();
  452. db_change_field('backup_migrate_profiles', 'filename', 'filename', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
  453. return $ret;
  454. }
  455. /**
  456. * Update the schedule last run times to use variables instead of saving with the schedule.
  457. */
  458. function backup_migrate_update_7203() {
  459. $result = db_query('SELECT * FROM {backup_migrate_schedules}', array(), array('fetch' => PDO::FETCH_ASSOC));
  460. foreach ($result as $item) {
  461. if (isset($item['last_run'])) {
  462. variable_set('backup_migrate_schedule_last_run_' . $item['schedule_id'], $item['last_run']);
  463. }
  464. }
  465. if (db_field_exists('backup_migrate_schedules', 'last_run')) {
  466. db_drop_field('backup_migrate_schedules', 'last_run');
  467. }
  468. }
  469. /**
  470. * Uninstall backup migrate files if it's installed
  471. */
  472. function backup_migrate_update_7300() {
  473. if (module_exists('backup_migrate_files')) {
  474. module_disable(array('backup_migrate_files'));
  475. $ret[] = array(
  476. 'success' => true,
  477. 'query' => 'Disabled the Backup and Migrate Files module',
  478. );
  479. }
  480. if (module_exists('nodesquirrel')) {
  481. module_disable(array('nodesquirrel'));
  482. $ret[] = array(
  483. 'success' => true,
  484. 'query' => 'Disabled the NodeSquirrel module',
  485. );
  486. }
  487. // Add sources to the schema.
  488. $schema['backup_migrate_sources'] = array(
  489. 'fields' => array(
  490. 'source_id' => array(
  491. 'type' => 'varchar',
  492. 'length' => 32,
  493. 'not null' => TRUE,
  494. 'default' => '0',
  495. 'description' => t('The primary identifier for a source.'),
  496. ),
  497. 'name' => array(
  498. 'description' => t('The name of the source.'),
  499. 'type' => 'varchar',
  500. 'length' => 255,
  501. 'not null' => TRUE
  502. ),
  503. 'type' => array(
  504. 'description' => t('The type of the source.'),
  505. 'type' => 'varchar',
  506. 'length' => 32,
  507. 'not null' => TRUE
  508. ),
  509. 'location' => array(
  510. 'description' => t('The the location string of the source.'),
  511. 'type' => 'text',
  512. 'not null' => TRUE
  513. ),
  514. 'settings' => array(
  515. 'description' => t('Other settings for the source.'),
  516. 'type' => 'text',
  517. 'not null' => TRUE,
  518. 'serialize' => TRUE,
  519. 'serialized default' => 'a:0:{}',
  520. ),
  521. ),
  522. 'primary key' => array('source_id'),
  523. );
  524. if (!db_table_exists('backup_migrate_sources')) {
  525. db_create_table('backup_migrate_sources', $schema['backup_migrate_sources']);
  526. }
  527. // Move custom destinations to sources.
  528. $result = db_query("SELECT * FROM {backup_migrate_destinations} WHERE type in ('filesource', 'db')", array(), array('fetch' => PDO::FETCH_ASSOC));
  529. foreach ($result as $item) {
  530. $item['source_id'] = $item['destination_id'];
  531. drupal_write_record('backup_migrate_source', $item);
  532. }
  533. // Change 'destination' settings to 'source' settings
  534. $result = db_query('SELECT * FROM {backup_migrate_profiles}', array(), array('fetch' => PDO::FETCH_ASSOC));
  535. foreach ($result as $item) {
  536. $item['filters'] = unserialize($item['filters']);
  537. $item['filters']['sources'] = $item['filters']['destinations'];
  538. unset($item['filters']['destinations']);
  539. drupal_write_record('backup_migrate_profiles', $item, array('profile_id'));
  540. }
  541. }
  542. /**
  543. * Switch the cron switch to text.
  544. */
  545. function backup_migrate_update_7301() {
  546. db_change_field('backup_migrate_schedules', 'cron', 'cron', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE));
  547. db_add_field('backup_migrate_schedules', 'cron_schedule', array('description' => 'The cron schedule to run on.', 'type' => 'varchar', 'length' => 255, 'default' => '0 4 * * *', 'not null' => TRUE));
  548. }
  549. /**
  550. * Add a second destination to schedules.
  551. */
  552. function backup_migrate_update_7302() {
  553. db_add_field('backup_migrate_schedules', 'copy_destination_id',
  554. array(
  555. 'type' => 'varchar',
  556. 'length' => 32,
  557. 'not null' => TRUE,
  558. 'default' => '0',
  559. 'description' => 'A second {backup_migrate_destination}.destination_id of the destination to copy the backup to.',
  560. )
  561. );
  562. }
  563. /**
  564. * Add a serial id field to all tables to allow them to be ctools exportable.
  565. */
  566. function backup_migrate_update_7303() {
  567. foreach (array('backup_migrate_sources' => 'source_id', 'backup_migrate_destinations' => 'destination_id', 'backup_migrate_schedules' => 'schedule_id', 'backup_migrate_profiles' => 'profile_id') as $table => $id) {
  568. db_drop_primary_key($table);
  569. db_change_field($table, $id, 'machine_name', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE));
  570. db_add_field($table, $id,
  571. array(
  572. 'type' => 'serial',
  573. 'unsigned' => TRUE,
  574. 'not null' => TRUE,
  575. 'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
  576. 'no export' => TRUE, // Do not export database-only keys.
  577. ),
  578. array('primary key' => array($id))
  579. );
  580. }
  581. foreach (array('backup_migrate_sources', 'backup_migrate_destinations') as $table) {
  582. db_change_field($table, 'type', 'subtype', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE));
  583. }
  584. }