- Patch #582948 by David_Rothstein: improve safety of schema manipulation.

merge-requests/26/head
Dries Buytaert 2010-03-20 15:06:51 +00:00
parent 5717ba536e
commit aadc94a102
4 changed files with 48 additions and 62 deletions

View File

@ -2477,9 +2477,7 @@ function db_next_id($existing_id = 0) {
* A Schema API table definition array.
*/
function db_create_table($name, $table) {
if (!db_table_exists($name)) {
return Database::getConnection()->schema()->createTable($name, $table);
}
return Database::getConnection()->schema()->createTable($name, $table);
}
/**

View File

@ -106,53 +106,55 @@ function update_prepare_d7_bootstrap() {
// The new cache_bootstrap bin is required to bootstrap to
// DRUPAL_BOOTSTRAP_SESSION, so create it here rather than in
// update_fix_d7_requirements().
$cache_bootstrap = array(
'description' => 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.',
'fields' => array(
'cid' => array(
'description' => 'Primary Key: Unique cache ID.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
if (!db_table_exists('cache_bootstrap')) {
$cache_bootstrap = array(
'description' => 'Cache table for data required to bootstrap Drupal, may be routed to a shared memory cache.',
'fields' => array(
'cid' => array(
'description' => 'Primary Key: Unique cache ID.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'data' => array(
'description' => 'A collection of data to cache.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
),
'expire' => array(
'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => 'A Unix timestamp indicating when the cache entry was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'headers' => array(
'description' => 'Any custom HTTP headers to be added to cached data.',
'type' => 'text',
'not null' => FALSE,
),
'serialized' => array(
'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
),
),
'data' => array(
'description' => 'A collection of data to cache.',
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'indexes' => array(
'expire' => array('expire'),
),
'expire' => array(
'description' => 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => 'A Unix timestamp indicating when the cache entry was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'headers' => array(
'description' => 'Any custom HTTP headers to be added to cached data.',
'type' => 'text',
'not null' => FALSE,
),
'serialized' => array(
'description' => 'A flag to indicate whether content is serialized (1) or not (0).',
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'expire' => array('expire'),
),
'primary key' => array('cid'),
);
db_create_table('cache_bootstrap', $cache_bootstrap);
'primary key' => array('cid'),
);
db_create_table('cache_bootstrap', $cache_bootstrap);
}
}
/**

View File

@ -2274,11 +2274,6 @@ function system_update_7042() {
db_drop_field('url_alias', 'source');
db_drop_field('url_alias', 'alias');
// Add the cache_path table.
$schema['cache_path'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_path']['description'] = 'Cache table used for path alias lookups.';
db_create_table('cache_path', $schema['cache_path']);
// Drop indexes.
db_drop_index('url_alias', 'src_language_pid');
db_drop_unique_key('url_alias', 'dst_language_pid');

View File

@ -1,19 +1,10 @@
<?php
// $Id$
/**
* Implements hook_install().
*/
function tracker_install() {
drupal_install_schema('tracker');
}
/**
* Implements hook_uninstall().
*/
function tracker_uninstall() {
drupal_uninstall_schema('tracker');
variable_del('tracker_index_nid');
variable_del('tracker_batch_size');
}