scanner.install 2.12 KB
Newer Older
1
2
3
4
5
6
7
<?php

/**
 * @file
 * Search and Replace Scanner install - creates necessary tables.
 */

8
9

/**
10
 * Implements hook_schema().
11
12
13
 */
function scanner_schema() {
  $schema['scanner'] = array(
14
    'description' => 'Holds info on recent replacements in case undo is needed.',
15
16
    'fields' => array(
      'undo_id' => array(
17
        'description' => 'Row identifier',
18
19
20
21
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'undo_data' => array(
22
        'description' => 'What was changed',
23
24
25
26
27
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE,
      ),
      'undone' => array(
28
        'description' => 'Whether the replacement has been undone',
29
30
31
32
33
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
      ),
      'searched' => array(
34
        'description' => 'Text that was searched for',
35
36
37
38
39
        'type' => 'varchar',
        'length' => 256,
        'not null' => TRUE,
      ),
      'replaced' => array(
40
        'description' => 'Text that was used as replacement',
41
42
43
44
45
        'type' => 'varchar',
        'length' => 256,
        'not null' => TRUE,
      ),
      'count' => array(
46
        'description' => 'How many fields were modified on replacement',
47
48
49
50
        'type' => 'int',
        'not null' => TRUE,
      ),
      'time' => array(
51
        'description' => 'How long the replacement took',
52
53
54
55
56
57
58
59
60
61
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array('undo_id'),
  );

  return $schema;
}

62
/**
63
 * Implements hook_install().
64
65
 */
function scanner_install() {
66
  // Create tables.
67
68
  // TODO The drupal_(un)install_schema functions are called automatically in D7.
  // drupal_install_schema('scanner')
69
70
71
}

/**
72
 * Implements hook_uninstall().
73
74
 */
function scanner_uninstall() {
75
  // Remove tables.
76
77
  // TODO The drupal_(un)install_schema functions are called automatically in D7.
  // drupal_uninstall_schema('scanner')
78

79
80
81
82
83
  // TODO Please review the conversion of this statement to the D7 database API syntax.
  /* db_query("DELETE FROM {variable} WHERE name LIKE 'scanner_%'") */
  //db_delete('variable')
  //->condition('name', 'scanner_%', 'LIKE')
  //->execute();
84
85
}