service_container.install 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * @file
  4. * Creates the following tables:
  5. *
  6. * - key_value
  7. * - key_value_expire
  8. */
  9. /**
  10. * Implements hook_schema().
  11. */
  12. function service_container_schema() {
  13. $schema = array();
  14. $schema['key_value'] = array(
  15. 'description' => 'Generic key-value storage table. See the state system for an example.',
  16. 'fields' => array(
  17. 'collection' => array(
  18. 'description' => 'A named collection of key and value pairs.',
  19. 'type' => 'varchar',
  20. 'length' => 128,
  21. 'not null' => TRUE,
  22. 'default' => '',
  23. ),
  24. 'name' => array(
  25. 'description' => 'The key of the key-value pair. As KEY is a SQL reserved keyword, name was chosen instead.',
  26. 'type' => 'varchar',
  27. 'length' => 128,
  28. 'not null' => TRUE,
  29. 'default' => '',
  30. ),
  31. 'value' => array(
  32. 'description' => 'The value.',
  33. 'type' => 'blob',
  34. 'not null' => TRUE,
  35. 'size' => 'big',
  36. ),
  37. ),
  38. 'primary key' => array('collection', 'name'),
  39. );
  40. $schema['key_value_expire'] = array(
  41. 'description' => 'Generic key/value storage table with an expiration.',
  42. 'fields' => array(
  43. 'collection' => array(
  44. 'description' => 'A named collection of key and value pairs.',
  45. 'type' => 'varchar',
  46. 'length' => 128,
  47. 'not null' => TRUE,
  48. 'default' => '',
  49. ),
  50. 'name' => array(
  51. // KEY is an SQL reserved word, so use 'name' as the key's field name.
  52. 'description' => 'The key of the key/value pair.',
  53. 'type' => 'varchar',
  54. 'length' => 128,
  55. 'not null' => TRUE,
  56. 'default' => '',
  57. ),
  58. 'value' => array(
  59. 'description' => 'The value of the key/value pair.',
  60. 'type' => 'blob',
  61. 'not null' => TRUE,
  62. 'size' => 'big',
  63. ),
  64. 'expire' => array(
  65. 'description' => 'The time since Unix epoch in seconds when this item expires. Defaults to the maximum possible time.',
  66. 'type' => 'int',
  67. 'not null' => TRUE,
  68. 'default' => 2147483647,
  69. ),
  70. ),
  71. 'primary key' => array('collection', 'name'),
  72. 'indexes' => array(
  73. 'all' => array('name', 'collection', 'expire'),
  74. 'expire' => array('expire'),
  75. ),
  76. );
  77. return $schema;
  78. }