book.install 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the book module.
  5. */
  6. /**
  7. * Implements hook_uninstall().
  8. */
  9. function book_uninstall() {
  10. // Clear book data out of the cache.
  11. \Drupal::cache('data')->deleteAll();
  12. }
  13. /**
  14. * Implements hook_schema().
  15. */
  16. function book_schema() {
  17. $schema['book'] = [
  18. 'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline',
  19. 'fields' => [
  20. 'nid' => [
  21. 'type' => 'int',
  22. 'unsigned' => TRUE,
  23. 'not null' => TRUE,
  24. 'default' => 0,
  25. 'description' => "The book page's {node}.nid.",
  26. ],
  27. 'bid' => [
  28. 'type' => 'int',
  29. 'unsigned' => TRUE,
  30. 'not null' => TRUE,
  31. 'default' => 0,
  32. 'description' => "The book ID is the {book}.nid of the top-level page.",
  33. ],
  34. 'pid' => [
  35. 'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its outline.',
  36. 'type' => 'int',
  37. 'unsigned' => TRUE,
  38. 'not null' => TRUE,
  39. 'default' => 0,
  40. ],
  41. 'has_children' => [
  42. 'description' => 'Flag indicating whether any nodes have this node as a parent (1 = children exist, 0 = no children).',
  43. 'type' => 'int',
  44. 'not null' => TRUE,
  45. 'default' => 0,
  46. 'size' => 'small',
  47. ],
  48. 'weight' => [
  49. 'description' => 'Weight among book entries in the same book at the same depth.',
  50. 'type' => 'int',
  51. 'not null' => TRUE,
  52. 'default' => 0,
  53. ],
  54. 'depth' => [
  55. 'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.',
  56. 'type' => 'int',
  57. 'not null' => TRUE,
  58. 'default' => 0,
  59. 'size' => 'small',
  60. ],
  61. 'p1' => [
  62. 'description' => 'The first nid in the materialized path. If N = depth, then pN must equal the nid. If depth > 1 then p(N-1) must equal the pid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.',
  63. 'type' => 'int',
  64. 'unsigned' => TRUE,
  65. 'not null' => TRUE,
  66. 'default' => 0,
  67. ],
  68. 'p2' => [
  69. 'description' => 'The second nid in the materialized path. See p1.',
  70. 'type' => 'int',
  71. 'unsigned' => TRUE,
  72. 'not null' => TRUE,
  73. 'default' => 0,
  74. ],
  75. 'p3' => [
  76. 'description' => 'The third nid in the materialized path. See p1.',
  77. 'type' => 'int',
  78. 'unsigned' => TRUE,
  79. 'not null' => TRUE,
  80. 'default' => 0,
  81. ],
  82. 'p4' => [
  83. 'description' => 'The fourth nid in the materialized path. See p1.',
  84. 'type' => 'int',
  85. 'unsigned' => TRUE,
  86. 'not null' => TRUE,
  87. 'default' => 0,
  88. ],
  89. 'p5' => [
  90. 'description' => 'The fifth nid in the materialized path. See p1.',
  91. 'type' => 'int',
  92. 'unsigned' => TRUE,
  93. 'not null' => TRUE,
  94. 'default' => 0,
  95. ],
  96. 'p6' => [
  97. 'description' => 'The sixth nid in the materialized path. See p1.',
  98. 'type' => 'int',
  99. 'unsigned' => TRUE,
  100. 'not null' => TRUE,
  101. 'default' => 0,
  102. ],
  103. 'p7' => [
  104. 'description' => 'The seventh nid in the materialized path. See p1.',
  105. 'type' => 'int',
  106. 'unsigned' => TRUE,
  107. 'not null' => TRUE,
  108. 'default' => 0,
  109. ],
  110. 'p8' => [
  111. 'description' => 'The eighth nid in the materialized path. See p1.',
  112. 'type' => 'int',
  113. 'unsigned' => TRUE,
  114. 'not null' => TRUE,
  115. 'default' => 0,
  116. ],
  117. 'p9' => [
  118. 'description' => 'The ninth nid in the materialized path. See p1.',
  119. 'type' => 'int',
  120. 'unsigned' => TRUE,
  121. 'not null' => TRUE,
  122. 'default' => 0,
  123. ],
  124. ],
  125. 'primary key' => ['nid'],
  126. 'indexes' => [
  127. 'book_parents' => ['bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'],
  128. ],
  129. ];
  130. return $schema;
  131. }