Newer
Older

Steven Wittens
committed
unset($_SESSION['system_update_179_uid']);
unset($_SESSION['system_update_179_fid']);
unset($_SESSION['system_update_179_max']);
return array();
}
else {
// Report percentage finished
// (Note: make sure we complete all fields for the last user by not reporting 100% too early)
return array('#finished' => $_SESSION['system_update_179_uid'] / ($_SESSION['system_update_179_max'] + 1));
}
}
return array();
}
function system_update_180() {
$ret = array();

Dries Buytaert
committed
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$ret[] = update_sql("ALTER TABLE {node} DROP INDEX vid");
$ret[] = update_sql("ALTER TABLE {node} ADD UNIQUE (vid)");
$ret[] = update_sql("ALTER TABLE {node} ADD INDEX (nid)");

Dries Buytaert
committed
$ret[] = update_sql("ALTER TABLE {node_counter} CHANGE nid nid int NOT NULL DEFAULT '0'");

Dries Buytaert
committed
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {node} DROP CONSTRAINT {node}_pkey"); // Change PK
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$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
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',

Steven Wittens
committed
'name' => t('Page'),

Neil Drumm
committed
'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',

Steven Wittens
committed
'name' => t('Story'),

Neil Drumm
committed
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
3255
3256
3257
3258
3259
3260
3261
3262
'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)');

Neil Drumm
committed
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.
*/