entity_translation_upgrade.install 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @file
  4. * Schema declaration for the entity_translation_upgrade module.
  5. */
  6. /**
  7. * Implements hook_schema().
  8. */
  9. function entity_translation_upgrade_schema() {
  10. $schema['entity_translation_upgrade_history'] = array(
  11. 'description' => 'The history table for node translations.',
  12. 'fields' => array(
  13. 'nid' => array(
  14. 'description' => 'The node translation nid.',
  15. 'type' => 'int',
  16. 'unsigned' => TRUE,
  17. 'not null' => TRUE,
  18. ),
  19. 'tnid' => array(
  20. 'description' => 'The translation set id for the node translation.',
  21. 'type' => 'int',
  22. 'unsigned' => TRUE,
  23. 'not null' => TRUE,
  24. ),
  25. 'language' => array(
  26. 'description' => 'The node translation language.',
  27. 'type' => 'varchar',
  28. 'length' => 12,
  29. 'not null' => TRUE,
  30. 'default' => '',
  31. ),
  32. 'complete' => array(
  33. 'description' => 'Boolean indicating whether the node migration has completed.',
  34. 'type' => 'int',
  35. 'not null' => TRUE,
  36. 'default' => 0,
  37. ),
  38. ),
  39. 'indexes' => array('tnid' => array('tnid'), 'complete' => array('complete')),
  40. 'primary key' => array('nid'),
  41. );
  42. return $schema;
  43. }
  44. /**
  45. * Implements hook_enable().
  46. */
  47. function entity_translation_upgrade_enable() {
  48. $args = array('!url' => url('admin/config/regional/entity_translation'));
  49. drupal_set_message(t('<em>Entity Translation Upgrade</em> enabled: visit the <a href="!url">entity translation settings</a> page to perform the upgrade.', $args));
  50. }
  51. /**
  52. * Implements hook_update_N().
  53. *
  54. * Adds the 'complete' column to the history table.
  55. */
  56. function entity_translation_upgrade_update_7001() {
  57. $table = 'entity_translation_upgrade_history';
  58. $name = 'complete';
  59. // Add the 'complete' field.
  60. $spec = array(
  61. 'description' => 'Boolean indicating whether the node migration has completed.',
  62. 'type' => 'int',
  63. 'not null' => TRUE,
  64. 'default' => 0,
  65. );
  66. db_add_field($table, $name, $spec);
  67. // Add the 'complete' index.
  68. db_add_index($table, $name, array($name));
  69. // Existing records are supposed to concern already completed migrations.
  70. db_update($table)
  71. ->fields(array('complete' => 1))
  72. ->execute();
  73. }