1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-06 15:45:34 +02:00
git-svn-id: file:///svn/phpbb/trunk@7074 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M 2007-02-25 21:23:00 +00:00
parent 409904c878
commit ef879f43f7

View File

@ -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!)
*/