module_test.install 806 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
<?php

/**
 * @file
 * Install, update and uninstall functions for the module_test module.
 */

/**
 * Implements hook_schema().
 */
function module_test_schema() {
12
  $schema['module_test'] = [
13
    'description' => 'Dummy table to test the behavior of hook_schema() during module installation.',
14 15
    'fields' => [
      'data' => [
16 17 18 19 20
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'An example data column for the module.',
21 22 23
      ],
    ],
  ];
24 25 26 27 28 29 30
  return $schema;
}

/**
 * Implements hook_install().
 */
function module_test_install() {
31
  $schema = drupal_get_module_schema('module_test', 'module_test');
32
  db_insert('module_test')
33
    ->fields([
34
      'data' => $schema['fields']['data']['type'],
35
    ])
36
    ->execute();
37
}