Index: acl.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/acl/acl.install,v retrieving revision 1.1.2.4 diff -u -r1.1.2.4 acl.install --- acl.install 9 Nov 2007 10:03:35 -0000 1.1.2.4 +++ acl.install 11 Nov 2007 14:58:18 -0000 @@ -9,26 +9,26 @@ acl_id int(10) NOT NULL default 0, module varchar(255), name varchar(255), - KEY acl_id (acl_id) - );"); + PRIMARY KEY (acl_id) + ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); db_query("create table if not exists {acl_user} ( acl_id int(10) NOT NULL default 0, uid int(10) NOT NULL default 0, - KEY acl_id (acl_id), + PRIMARY KEY (acl_id, uid), KEY uid (uid) - );"); - + ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); + db_query("create table if not exists {acl_node} ( acl_id int(10) NOT NULL default 0, nid int(10) NOT NULL default 0, grant_view tinyint(1) unsigned NOT NULL default '0', grant_update tinyint(1) unsigned NOT NULL default '0', grant_delete tinyint(1) unsigned NOT NULL default '0', - KEY acl_id (acl_id), - KEY nid (nid) - );"); + PRIMARY KEY (acl_id, nid) + ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); break; + case 'pgsql': db_query("CREATE TABLE {acl} ( acl_id integer NOT NULL DEFAULT 0, @@ -41,26 +41,37 @@ db_query("CREATE TABLE {acl_user} ( acl_id integer NOT NULL DEFAULT 0, uid int NOT NULL DEFAULT 0, - PRIMARY KEY (acl_id) + PRIMARY KEY (acl_id, uid) );"); - + db_query("CREATE INDEX {acl_user_uid_index} ON {acl_user} (uid)"); + db_query("CREATE TABLE {acl_node} ( acl_id integer NOT NULL DEFAULT 0, nid int NOT NULL DEFAULT 0, grant_view smallint NOT NULL default 0, grant_update smallint NOT NULL default 0, grant_delete smallint NOT NULL default 0, - PRIMARY KEY (acl_id) + PRIMARY KEY (acl_id, nid) );"); - - db_query("CREATE INDEX {acl_node}_nid ON {acl_node} (nid)"); - break; } - drupal_set_message("acl database tables created."); } -// fix our sequences entry to support database prefixes +/* + * Implementation of hook_uninstall + */ +function acl_uninstall() { + if ($GLOBALS['db_type'] == 'pgsql') { + db_query('DROP INDEX {acl_user_uid_index}'); + } + db_query('DROP TABLE {acl}'); + db_query('DROP TABLE {acl_user}'); + db_query('DROP TABLE {acl_node}'); +} + +/** + * Fixes table prefix + */ function acl_update_1() { $ret = array(); switch ($GLOBALS['db_type']) { @@ -78,3 +89,55 @@ } return $ret; } + +/** + * Fixes primary keys + */ +function acl_update_2() { + $ret = array(); + switch ($GLOBALS['db_type']) { + case 'mysqli': + case 'mysql': + // drop the previously created indexes (except for acl_user.uid) + $ret[] = update_sql('ALTER TABLE {acl} DROP INDEX acl_id'); + $ret[] = update_sql('ALTER TABLE {acl_user} DROP INDEX acl_id'); + $ret[] = update_sql('ALTER TABLE {acl_node} DROP INDEX acl_id'); + $ret[] = update_sql('ALTER TABLE {acl_node} DROP INDEX nid'); + // create new indexes (as primary keys this time) + $ret[] = update_sql('ALTER TABLE {acl} ADD PRIMARY KEY (acl_id)'); + $ret[] = update_sql('ALTER TABLE {acl_user} ADD PRIMARY KEY (acl_id, uid)'); + $ret[] = update_sql('ALTER TABLE {acl_node} ADD PRIMARY KEY (acl_id, nid)'); + break; + + case 'pgsql': + $ret[] = update_sql('ALTER TABLE {acl} DROP PRIMARY KEY , ADD PRIMARY KEY (acl_id)'); + $ret[] = update_sql('ALTER TABLE {acl_user} DROP PRIMARY KEY , ADD PRIMARY KEY (acl_id, uid)'); + $ret[] = update_sql('ALTER TABLE {acl_node} DROP PRIMARY KEY , ADD PRIMARY KEY (acl_id, nid)'); + $ret[] = update_sql('CREATE INDEX {acl_user_uid_index} ON {acl_user} (uid)'); + break; + } + return $ret; +} + +/* + * Updates tables to use utf8 for mysql + */ +function acl_update_3() { + $ret = array(); + // Only for MySQL 4.1+ + switch ($GLOBALS['db_type']) { + case 'mysqli': + break; + case 'mysql': + if (version_compare(mysql_get_server_info($GLOBALS['active_db']), '4.1.0', '<')) { + return array(); + } + break; + case 'pgsql': + return array(); + } + $ret = update_convert_table_utf8('acl'); + $ret = array_merge($ret, update_convert_table_utf8('acl_node')); + $ret = array_merge($ret, update_convert_table_utf8('acl_user')); + return $ret; +} Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/acl/Attic/CHANGELOG.txt,v retrieving revision 1.1.2.6 diff -u -r1.1.2.6 CHANGELOG.txt --- CHANGELOG.txt 9 Nov 2007 10:03:35 -0000 1.1.2.6 +++ CHANGELOG.txt 11 Nov 2007 14:58:18 -0000 @@ -2,6 +2,7 @@ ACL 5.x-1.x: Bugs fixed: + o fixed acl db scheme (primary keys, utf8) and added an uninstallation routine o acl_id created without $db_prefix when using shared table.