Newer
Older

Dries Buytaert
committed
$ret[] = update_sql('DROP INDEX {node}_vid_idx'); // Change normal index to UNIQUE index
$ret[] = update_sql('CREATE UNIQUE INDEX {node}_vid_idx ON {node}(vid)');
$ret[] = update_sql('CREATE INDEX {node}_nid_idx ON {node}(nid)'); // Add index on nid
break;
}
return $ret;
}

Dries Buytaert
committed
function system_update_181() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':

Dries Buytaert
committed
$ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYint NOT NULL AFTER visibility ;");

Dries Buytaert
committed
break;
case 'pgsql':

Dries Buytaert
committed
db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint', array('not null' => TRUE, 'default' => 0));

Dries Buytaert
committed
break;
}
return $ret;
}

Dries Buytaert
committed
/**
* The lid field in pgSQL should not be UNIQUE, but an INDEX.
*/
function system_update_182() {
$ret = array();
if ($GLOBALS['db_type'] == 'pgsql') {

Dries Buytaert
committed
$ret[] = update_sql('ALTER TABLE {locales_target} DROP CONSTRAINT {locales_target}_lid_key');

Dries Buytaert
committed
$ret[] = update_sql('CREATE INDEX {locales_target}_lid_idx ON {locales_target} (lid)');
}
return $ret;
}

Dries Buytaert
committed
/**
* @defgroup updates-4.7-to-x.x System updates from 4.7 to x.x
* @{
*/
function system_update_1000() {

Dries Buytaert
committed
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("CREATE TABLE {blocks_roles} (

Dries Buytaert
committed
module varchar(64) NOT NULL,
delta varchar(32) NOT NULL,

Dries Buytaert
committed
rid int unsigned NOT NULL,

Dries Buytaert
committed
PRIMARY KEY (module, delta, rid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$ret[] = update_sql("CREATE TABLE {blocks_roles} (

Dries Buytaert
committed
module varchar(64) NOT NULL,
delta varchar(32) NOT NULL,
rid integer NOT NULL,
PRIMARY KEY (module, delta, rid)
);");
break;
}
return $ret;
}

Dries Buytaert
committed
function system_update_1001() {

Dries Buytaert
committed
// change DB schema for better poll support
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
// alter poll_votes table

Dries Buytaert
committed
$ret[] = update_sql("ALTER TABLE {poll_votes} ADD COLUMN chorder int NOT NULL default -1 AFTER uid");

Dries Buytaert
committed
break;
case 'pgsql':
db_add_column($ret, 'poll_votes', 'chorder', 'int', array('not null' => TRUE, 'default' => "'-1'"));
break;
}
return $ret;
}
function system_update_1002() {

Dries Buytaert
committed
// Make the forum's vocabulary the highest in list, if present
$ret = array();
if ($vid = (int) variable_get('forum_nav_vocabulary', 0)) {
$ret[] = update_sql('UPDATE {vocabulary} SET weight = -10 WHERE vid = '. $vid);

Dries Buytaert
committed
}
return $ret;
}
function system_update_1003() {

Dries Buytaert
committed
// Make use of guid in feed items
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {aggregator_item} ADD guid varchar(255) AFTER timestamp ;");
break;
case 'pgsql':
db_add_column($ret, 'aggregator_item', 'guid', 'varchar(255)');
break;
}
return $ret;
}
function system_update_1004() {

Dries Buytaert
committed
// Increase the size of bid in boxes and aid in access
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {access} CHANGE `aid` `aid` INT( 10 ) NOT NULL AUTO_INCREMENT ");
$ret[] = update_sql("ALTER TABLE {boxes} CHANGE `bid` `bid` INT( 10 ) NOT NULL AUTO_INCREMENT ");
break;
case 'pgsql':
// No database update required for PostgreSQL because it already uses big SERIAL numbers.
break;
}
return $ret;
}

Neil Drumm
committed
function system_update_1005() {

Neil Drumm
committed
// Add ability to create dynamic node types like the CCK module
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
// Create node_type table
$ret[] = update_sql("CREATE TABLE {node_type} (
type varchar(32) NOT NULL,
name varchar(255) NOT NULL,
module varchar(255) NOT NULL,
description mediumtext NOT NULL,
help mediumtext NOT NULL,

Dries Buytaert
committed
has_title tinyint unsigned NOT NULL,

Neil Drumm
committed
title_label varchar(255) NOT NULL default '',

Dries Buytaert
committed
has_body tinyint unsigned NOT NULL,

Neil Drumm
committed
body_label varchar(255) NOT NULL default '',

Dries Buytaert
committed
min_word_count smallint unsigned NOT NULL,
custom tinyint NOT NULL DEFAULT '0',
modified tinyint NOT NULL DEFAULT '0',
locked tinyint NOT NULL DEFAULT '0',

Neil Drumm
committed
orig_type varchar(255) NOT NULL default '',
PRIMARY KEY (type)
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
// add new unsigned types for pgsql
$ret[] = update_sql("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)");
$ret[] = update_sql("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)");
$ret[] = update_sql("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");

Neil Drumm
committed
$ret[] = update_sql("CREATE TABLE {node_type} (
type varchar(32) NOT NULL,
name varchar(255) NOT NULL,
module varchar(255) NOT NULL,
description text NOT NULL,
help text NOT NULL,
has_title smallint_unsigned NOT NULL,

Neil Drumm
committed
title_label varchar(255) NOT NULL default '',
has_body smallint_unsigned NOT NULL,

Neil Drumm
committed
body_label varchar(255) NOT NULL default '',
min_word_count smallint_unsigned NOT NULL,

Neil Drumm
committed
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
custom smallint NOT NULL DEFAULT '0',
modified smallint NOT NULL DEFAULT '0',
locked smallint NOT NULL DEFAULT '0',
orig_type varchar(255) NOT NULL default '',
PRIMARY KEY (type)
);");
break;
}
// Insert default user-defined node types into the database.
$types = array(
array(
'type' => 'page',
'name' => t('page'),
'module' => 'node',
'description' => t('If you want to add a static page, like a contact page or an about page, use a page.'),
'custom' => TRUE,
'modified' => TRUE,
'locked' => FALSE,
),
array(
'type' => 'story',
'name' => t('story'),
'module' => 'node',
'description' => t('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extendd by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.'),
'custom' => TRUE,
'modified' => TRUE,
'locked' => FALSE,
)
);
foreach ($types as $type) {
$type = (object) _node_type_set_defaults($type);
node_type_save($type);
}
cache_clear_all();
system_modules();
menu_rebuild();
node_types_rebuild();
// Migrate old values for 'minimum_x_size' variables to the node_type table.
$query = db_query('SELECT type FROM {node_type}');
while ($result = db_fetch_object($query)) {
$variable_name = 'minimum_'. $result->type .'_size';
if ($value = db_fetch_object(db_query("SELECT value FROM {variable} WHERE name = '%s'", $variable_name))) {
$value = (int) unserialize($value->value);
db_query("UPDATE {node_type} SET min_word_count = %d, modified = %d WHERE type = '%s'", $value, 1, $result->type);
variable_del($variable_name);
}
}
node_types_rebuild();
return $ret;
}
function system_update_1006() {
// Add a customizable title to all blocks.
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {blocks} ADD title VARCHAR(64) NOT NULL DEFAULT ''");
break;
case 'pgsql':

Dries Buytaert
committed
db_add_column($ret, 'blocks', 'title', 'varchar(64)', array('default' => "''", 'not null' => TRUE));
break;
}
// Migrate custom block titles to new column.
$boxes = db_query('SELECT bid, title from {boxes}');
while ($box = db_fetch_object($boxes)) {
db_query("UPDATE {blocks} SET title = '%s' WHERE delta = %d and module = 'block'", $box->title, $box->bid);
}
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {boxes} DROP title');
break;
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {boxes} DROP COLUMN title');
break;
}
return $ret;
}
function system_update_1007() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {aggregator_item} ADD INDEX (fid)");
break;
case 'pgsql':
$ret[] = update_sql("CREATE INDEX {aggregator_item}_fid_idx ON {aggregator_item} (fid)");
break;
}
return $ret;
}

Dries Buytaert
committed
/**
* Performance update for queries that are related to the locale.module
*/
function system_update_1008() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {locales_source} ADD KEY source (source(30))');
break;
case 'pgsql':
$ret[] = update_sql("CREATE INDEX {locales_source}_source_idx on {locales_source} (source)");
}
return $ret;
function system_update_1010() {
$ret = array();
// Disable urlfilter.module, if it exists.
if (module_exists('urlfilter')) {
module_disable('urlfilter');
$ret[] = update_sql("UPDATE {filter_formats} SET module = 'filter', delta = 3 WHERE module = 'urlfilter'");
$ret[] = t('URL Filter module was disabled; this functionality has now been added to core.');
}
return $ret;
}
function system_update_1011() {
$ret = array();
$ret[] = update_sql('UPDATE {menu} SET mid = 2 WHERE mid = 0');
cache_clear_all();
return $ret;
}

Neil Drumm
committed
function system_update_1012() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {file_revisions} ADD INDEX(vid)");
break;
case 'pgsql':
$ret[] = update_sql('CREATE INDEX {file_revisions}_vid_idx ON {file_revisions}(vid)');
break;
}
return $ret;
}
function system_update_1013() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql('ALTER TABLE {sessions} CHANGE COLUMN sid sid varchar(64)');
break;
case 'pgsql':
$ret[] = update_sql('ALTER TABLE {sessions} ALTER COLUMN sid TYPE varchar(64)');
break;
}
return $ret;
}
function system_update_1014() {
variable_del('cron_busy');
return array();
}
/**
* @} End of "defgroup updates-4.7-to-x.x"
* The next series of updates should start at 2000.
*/