diff options
author | David M <davidmj@users.sourceforge.net> | 2007-02-25 21:23:00 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2007-02-25 21:23:00 +0000 |
commit | ef879f43f71fd35ecf9a213acc1052db66fe8046 (patch) | |
tree | 2370139eac14c5b304bd3dcdc87f22bab57ca361 | |
parent | 409904c8788949a765a591673003f511f6bf8ed0 (diff) | |
download | forums-ef879f43f71fd35ecf9a213acc1052db66fe8046.tar forums-ef879f43f71fd35ecf9a213acc1052db66fe8046.tar.gz forums-ef879f43f71fd35ecf9a213acc1052db66fe8046.tar.bz2 forums-ef879f43f71fd35ecf9a213acc1052db66fe8046.tar.xz forums-ef879f43f71fd35ecf9a213acc1052db66fe8046.zip |
#7882
git-svn-id: file:///svn/phpbb/trunk@7074 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/install/database_update.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 26c3e6ccac..6d940eab1b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -361,6 +361,18 @@ $database_update_info = array( 'session_forwarded_for' => array('VCHAR:255', ''), ), ), + // Remove the following keys + 'drop_keys' => array( + USERS_TABLE => array( + 'username_clean', + ), + ), + // Add the following unique indexes + 'add_unique_index' => array( + USERS_TABLE => array( + 'username_clean' => array('username_clean'), + ), + ), ), ); @@ -546,6 +558,18 @@ foreach ($database_update_info as $version => $schema_changes) sql_create_primary_key($map_dbms, $table, $columns); } } + + // Add unqiue indexes? + if (!empty($schema_changes['add_unique_index'])) + { + foreach ($schema_changes['add_unique_index'] as $table => $index_array) + { + foreach ($index_array as $index_name => $column) + { + sql_create_unique_index($dbms, $index_name, $table_name, $column); + } + } + } } _write_result($no_updates, $errored, $error_ary); @@ -1219,6 +1243,30 @@ function sql_create_primary_key($dbms, $table_name, $column) } } +function sql_create_unique_index($dbms, $index_name, $table_name, $column) +{ + global $dbms_type_map, $db; + global $errored, $error_ary; + + switch ($dbms) + { + case 'firebird': + case 'postgres': + case 'mysql_40': + case 'mysql_41': + case 'oracle': + case 'sqlite': + $sql = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + _sql($sql, $errored, $error_ary); + break; + + case 'mssql': + $sql = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; + _sql($sql, $errored, $error_ary); + break; + } +} + /** * Change column type (not name!) */ |