block_class.install 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the block_class module.
  5. */
  6. /**
  7. * Implementation of hook_schema().
  8. */
  9. function block_class_schema() {
  10. $schema['block_class'] = array(
  11. 'fields' => array(
  12. 'module' => array(
  13. 'type' => 'varchar',
  14. 'length' => 64,
  15. 'not null' => TRUE,
  16. 'default' => '',
  17. 'description' => 'The module to which the block belongs.',
  18. ),
  19. 'delta' => array(
  20. 'type' => 'varchar',
  21. 'length' => 32,
  22. 'not null' => TRUE,
  23. 'default' => '',
  24. 'description' => "The ID of the module's block.",
  25. ),
  26. 'css_class' => array(
  27. 'type' => 'varchar',
  28. 'length' => 255,
  29. 'not null' => TRUE,
  30. 'default' => '',
  31. 'description' => 'String containing the classes for the block.',
  32. ),
  33. ),
  34. 'primary key' => array('module', 'delta'),
  35. );
  36. return $schema;
  37. }
  38. /**
  39. * Alters the structure of {block_class} schema.
  40. */
  41. function block_class_update_7100() {
  42. // Update the schema.
  43. db_drop_primary_key('block_class');
  44. db_change_field('block_class', 'module', 'module',
  45. array(
  46. 'type' => 'varchar',
  47. 'length' => '255',
  48. 'not null' => TRUE,
  49. 'default' => '',
  50. 'description' => 'The module to which the block belongs.',
  51. )
  52. );
  53. db_change_field('block_class', 'delta', 'delta',
  54. array(
  55. 'type' => 'varchar',
  56. 'length' => '255',
  57. 'not null' => TRUE,
  58. 'default' => '',
  59. 'description' => "The ID of the module's block.",
  60. )
  61. );
  62. db_change_field('block_class', 'css_class', 'css_class',
  63. array(
  64. 'type' => 'varchar',
  65. 'length' => '255',
  66. 'not null' => TRUE,
  67. 'default' => '',
  68. 'description' => 'String containing the classes for the block.',
  69. )
  70. );
  71. // Restore the primary key.
  72. db_add_primary_key('block_class', array('module', 'delta'));
  73. }
  74. /**
  75. * Fix too long primary key length in {block_class}.
  76. */
  77. function block_class_update_7101() {
  78. // Drop current primary key.
  79. db_drop_primary_key('block_class');
  80. db_change_field('block_class', 'module', 'module', array(
  81. 'type' => 'varchar',
  82. 'length' => 64,
  83. 'not null' => TRUE,
  84. 'default' => '',
  85. 'description' => 'The module to which the block belongs.',
  86. ));
  87. db_change_field('block_class', 'delta', 'delta', array(
  88. 'type' => 'varchar',
  89. 'length' => 32,
  90. 'not null' => TRUE,
  91. 'default' => '',
  92. 'description' => "The ID of the module's block.",
  93. ));
  94. // Create new primary key.
  95. db_add_primary_key('block_class', array('module', 'delta'));
  96. }