Newer
Older

Dries Buytaert
committed
$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
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
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
orig_type varchar(255) NOT NULL default '',
PRIMARY KEY (type)
) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$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 integer unsigned NOT NULL,
title_label varchar(255) NOT NULL default '',
has_body integer unsigned NOT NULL,
body_label varchar(255) NOT NULL default '',
min_word_count integer unsigned NOT NULL,
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;
}
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
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':
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;
}
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
function system_update_1009() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("CREATE TABLE {cache_filter} (
cid varchar(255) NOT NULL default '',
data longblob,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid),
INDEX expire (expire)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
$ret[] = update_sql("CREATE TABLE {cache_menu} (
cid varchar(255) NOT NULL default '',
data longblob,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid),
INDEX expire (expire)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
$ret[] = update_sql("CREATE TABLE {cache_page} (
cid varchar(255) NOT NULL default '',
data longblob,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid),
INDEX expire (expire)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
$ret[] = update_sql("CREATE TABLE {cache_filter} (
cid varchar(255) NOT NULL default '',
data bytea,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid)
)");
$ret[] = update_sql("CREATE TABLE {cache_menu} (
cid varchar(255) NOT NULL default '',
data bytea,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid)
)");
$ret[] = update_sql("CREATE TABLE {cache_page} (
cid varchar(255) NOT NULL default '',
data bytea,
expire int NOT NULL default '0',
created int NOT NULL default '0',
headers text,
PRIMARY KEY (cid)
)");
$ret[] = update_sql("CREATE INDEX {cache_filter}_expire_idx ON {cache_filter} (expire)");
$ret[] = update_sql("CREATE INDEX {cache_menu}_expire_idx ON {cache_menu} (expire)");
$ret[] = update_sql("CREATE INDEX {cache_page}_expire_idx ON {cache_page} (expire)");
break;
}
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;
}
/**
* @} End of "defgroup updates-4.7-to-x.x"
* The next series of updates should start at 2000.
*/