view core/modules/system/tests/modules/module_test/module_test.install @ 9:1fc0ff908d1f

Add another data file
author Chris Cannam
date Mon, 05 Feb 2018 12:34:32 +0000
parents 4c8ae668cc8c
children 1fec387a4317
line wrap: on
line source
<?php

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

/**
 * Implements hook_schema().
 */
function module_test_schema() {
  $schema['module_test'] = [
    'description' => 'Dummy table to test the behavior of hook_schema() during module installation.',
    'fields' => [
      'data' => [
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'An example data column for the module.',
      ],
    ],
  ];
  return $schema;
}

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