draggableviews.install 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * @file
  4. * Draggableviews defines a new database schema
  5. * for saving the order.
  6. */
  7. /**
  8. * Implements hook_schema().
  9. */
  10. function draggableviews_schema() {
  11. $schema['draggableviews_structure'] = array(
  12. 'description' => 'The table saves the order settings of an draggableview.',
  13. 'fields' => array(
  14. 'dvid' => array(
  15. 'description' => 'The primary identifier.',
  16. 'type' => 'serial',
  17. 'unsigned' => TRUE,
  18. 'not null' => TRUE,
  19. ),
  20. 'view_name' => array(
  21. 'description' => 'Makes the order unique for each view.',
  22. 'type' => 'varchar',
  23. 'length' => 128,
  24. 'not null' => TRUE,
  25. 'default' => '',
  26. ),
  27. 'view_display' => array(
  28. 'description' => 'Makes the order unique for each view display.',
  29. 'type' => 'varchar',
  30. 'length' => 64,
  31. 'not null' => TRUE,
  32. 'default' => '',
  33. ),
  34. 'args' => array(
  35. 'description' => 'Makes the order unique for a given set of arguments',
  36. 'type' => 'varchar',
  37. 'length' => 255,
  38. 'not null' => FALSE,
  39. 'default' => '',
  40. ),
  41. 'entity_id' => array(
  42. 'description' => 'Id of the entity that we are sorting (node, user, etc.).',
  43. 'type' => 'int',
  44. 'unsigned' => TRUE,
  45. 'not null' => TRUE,
  46. ),
  47. 'weight' => array(
  48. 'description' => 'The order weight.',
  49. 'type' => 'int',
  50. 'unsigned' => FALSE,
  51. 'not null' => TRUE,
  52. 'default' => 0,
  53. ),
  54. ),
  55. 'unique keys' => array(
  56. 'dvid' => array('dvid'),
  57. ),
  58. 'primary key' => array('dvid'),
  59. );
  60. return $schema;
  61. }
  62. /**
  63. * Increase sizes of view_name and view_display fields of
  64. * draggableviews_strucutre table.
  65. */
  66. function draggableviews_update_7001() {
  67. $new_field = array(
  68. 'description' => 'Makes the order unique for each view.',
  69. 'type' => 'varchar',
  70. 'length' => 128,
  71. 'not null' => TRUE,
  72. 'default' => '',
  73. );
  74. db_change_field('draggableviews_structure', 'view_name', 'view_name', $new_field);
  75. $new_field = array(
  76. 'description' => 'Makes the order unique for each view display.',
  77. 'type' => 'varchar',
  78. 'length' => 64,
  79. 'not null' => TRUE,
  80. 'default' => '',
  81. );
  82. db_change_field('draggableviews_structure', 'view_display', 'view_display', $new_field);
  83. }