Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merged from MOODLE_15_STABLE: (ish, version numbers different): Add a…
…n index where we really need it - block_instance.pagetype
  • Loading branch information
mjollnir_ committed Sep 2, 2005
1 parent f64376b commit c69dbe6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
7 changes: 6 additions & 1 deletion blocks/db/mysql.php
Expand Up @@ -155,7 +155,12 @@ function blocks_upgrade($oldversion=0) {
PRIMARY KEY(`id`)
) TYPE=MyISAM;");
}


if ($oldversion < 2005090200) {
execute_sql("ALTER TABLE {$CFG->prefix}block_instance ADD INDEX pagetype (pagetype);",false); // do it silently, in case it's already there from 1.5
modify_database('','ALTER TABLE prefix_block_pinned ADD INDEX pagetype (pagetype);');
}

//Finally, return result
return $result;
}
Expand Down
3 changes: 2 additions & 1 deletion blocks/db/mysql.sql
Expand Up @@ -24,7 +24,8 @@ CREATE TABLE `prefix_block_instance` (
`visible` tinyint(1) not null default '0',
`configdata` text not null default '',
PRIMARY KEY(`id`),
INDEX pageid(`pageid`)
INDEX pageid(`pageid`),
INDEX pagetype(`pagetype`)
) TYPE=MyISAM;

CREATE TABLE `prefix_block_pinned` (
Expand Down
7 changes: 6 additions & 1 deletion blocks/db/postgres7.php
Expand Up @@ -139,7 +139,7 @@ function blocks_upgrade($oldversion=0) {
}

if ($oldversion < 2005022401 && $result) { // Mass cleanup of bad upgrade scripts
modify_database('','CREATE INDEX prefix_block_instance_pageid_idx ON prefix_block_instance (pageid)');
execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pageid_idx ON {$CFG->prefix}block_instance (pageid)",false); // this one should be quiet...
modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET DEFAULT \'\'');
modify_database('','ALTER TABLE prefix_block_instance ALTER position SET DEFAULT \'\'');
modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET NOT NULL');
Expand All @@ -158,6 +158,11 @@ function blocks_upgrade($oldversion=0) {
);");
}

if ($oldversion < 2005090200) {
execute_sql("CREATE INDEX {$CFG->prefix}block_instance_pagetype_idx ON {$CFG->prefix}block_instance (pagetype);",false); // do it silently, in case it's already there from 1.5
modify_database('','CREATE INDEX prefix_block_pinned_pagetype_idx ON prefix_block_pinned (pagetype);');
}

//Finally, return result
return $result;
}
Expand Down
3 changes: 3 additions & 0 deletions blocks/db/postgres7.sql
Expand Up @@ -24,6 +24,7 @@ CREATE TABLE prefix_block_instance (
configdata text not null default ''
) ;
CREATE INDEX prefix_block_instance_pageid_idx ON prefix_block_instance (pageid);
CREATE INDEX prefix_block_instance_pagetype_idx ON prefix_block_instance (pagetype);

CREATE TABLE prefix_block_pinned (
id SERIAL8 PRIMARY KEY,
Expand All @@ -35,4 +36,6 @@ CREATE TABLE prefix_block_pinned (
configdata text NOT NULL default 0
) ;

CREATE INDEX prefix_block_pinned_pagetype_idx ON prefix_block_pinned (pagetype);

# --------------------------------------------------------
2 changes: 1 addition & 1 deletion blocks/version.php
Expand Up @@ -5,4 +5,4 @@
// database (blocks_version) to determine whether upgrades should
// be performed (see db/backup_*.php)

$blocks_version = 2005081600; // The current version is a date (YYYYMMDDXX)
$blocks_version = 2005090200; // The current version is a date (YYYYMMDDXX)

0 comments on commit c69dbe6

Please sign in to comment.