Commit 6d498d64 authored by JohnAlbin's avatar JohnAlbin
Browse files

Added db updates from DRUPAL-5--1.

parent 488ce265
...@@ -2,6 +2,8 @@ Page Title 5.x-1.1 ...@@ -2,6 +2,8 @@ Page Title 5.x-1.1
* Added Russian translation by SadhooKlay. * Added Russian translation by SadhooKlay.
* Removed inaccurate package description from .info file. * Removed inaccurate package description from .info file.
* Added ability to uninstall module. * Added ability to uninstall module.
* Increased length of page title to 255 characters for MySQL users.
#158104: Updated MySQL tables to use the system default table type instead of always using MyISAM.
Page Title 5.x-1.0 Page Title 5.x-1.0
* Initial release. * Initial release.
...@@ -5,31 +5,26 @@ ...@@ -5,31 +5,26 @@
* Implementation of hook_install(). * Implementation of hook_install().
*/ */
function page_title_install() { function page_title_install() {
$result = FALSE;
switch ($GLOBALS['db_type']) { switch ($GLOBALS['db_type']) {
case 'mysqli': case 'mysqli':
case 'mysql': case 'mysql':
$query1 = db_query("CREATE TABLE IF NOT EXISTS {page_title} ( $result = db_query('CREATE TABLE IF NOT EXISTS {page_title} (
nid INT NOT NULL, nid INT NOT NULL,
page_title VARCHAR( 128 ) NOT NULL, page_title VARCHAR(255) NOT NULL,
PRIMARY KEY ( `nid` ) PRIMARY KEY (nid)
) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"); ) /*!40100 DEFAULT CHARACTER SET utf8 */');
if ($query1) {
$created = TRUE;
}
break; break;
case 'pgsql': case 'pgsql':
$query1 = db_query("CREATE TABLE {page_title} ( $result = db_query("CREATE TABLE {page_title} (
nid integer NOT NULL default '0', nid integer NOT NULL default '0',
page_title text NOT NULL default '' page_title text NOT NULL default ''
);"); )");
if ($query1) {
$created = TRUE;
}
break; break;
} }
if ($created) { if ($result) {
drupal_set_message(t('Page title module installed successfully.')); drupal_set_message(t('Page title module installed successfully.'));
} }
else { else {
...@@ -43,3 +38,28 @@ function page_title_install() { ...@@ -43,3 +38,28 @@ function page_title_install() {
function page_title_uninstall() { function page_title_uninstall() {
db_query('DROP TABLE {page_title}'); db_query('DROP TABLE {page_title}');
} }
/**
* Increases page title in MySQL to 255 characters and modifies the MySQL table type from MYISAM to the user's default type.
*
* Implementation of hook_update_N().
*/
function page_title_update_1() {
$items = array();
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$items[] = update_sql('ALTER TABLE {page_title} MODIFY COLUMN page_title VARCHAR(255) NOT NULL');
$items[] = update_sql('CREATE TEMPORARY TABLE {page_title_temp} AS SELECT * FROM {page_title}');
$items[] = update_sql('DROP TABLE {page_title}');
$items[] = update_sql('CREATE TABLE {page_title} (
nid INT NOT NULL,
page_title VARCHAR(255) NOT NULL,
PRIMARY KEY (nid)
) /*!40100 DEFAULT CHARACTER SET utf8 */;');
$items[] = update_sql('INSERT INTO {page_title} (nid, page_title)
SELECT nid, page_title FROM {page_title_temp}');
$items[] = update_sql('DROP TABLE {page_title_temp}');
}
return $items;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment