mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-03 07:18:08 +02:00
fix creating index and add more checking to schema changes
git-svn-id: file:///svn/phpbb/trunk@9348 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -295,8 +295,16 @@ class phpbb_db_tools
|
|||||||
foreach ($schema_changes['change_columns'] as $table => $columns)
|
foreach ($schema_changes['change_columns'] as $table => $columns)
|
||||||
{
|
{
|
||||||
foreach ($columns as $column_name => $column_data)
|
foreach ($columns as $column_name => $column_data)
|
||||||
|
{
|
||||||
|
// If the column exists we change it, else we add it ;)
|
||||||
|
if ($this->sql_column_exists($table, $column_name))
|
||||||
{
|
{
|
||||||
$result = $this->sql_column_change($table, $column_name, $column_data);
|
$result = $this->sql_column_change($table, $column_name, $column_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = $this->sql_column_add($table, $column_name, $column_data);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->return_statements)
|
if ($this->return_statements)
|
||||||
{
|
{
|
||||||
@@ -313,10 +321,15 @@ class phpbb_db_tools
|
|||||||
{
|
{
|
||||||
foreach ($columns as $column_name => $column_data)
|
foreach ($columns as $column_name => $column_data)
|
||||||
{
|
{
|
||||||
// Only add the column if it does not exist yet
|
// Only add the column if it does not exist yet, else change it (to be consistent)
|
||||||
if (!$this->sql_column_exists($table, $column_name))
|
if ($this->sql_column_exists($table, $column_name))
|
||||||
|
{
|
||||||
|
$result = $this->sql_column_change($table, $column_name, $column_data);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$result = $this->sql_column_add($table, $column_name, $column_data);
|
$result = $this->sql_column_add($table, $column_name, $column_data);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->return_statements)
|
if ($this->return_statements)
|
||||||
{
|
{
|
||||||
@@ -325,7 +338,6 @@ class phpbb_db_tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Remove keys?
|
// Remove keys?
|
||||||
if (!empty($schema_changes['drop_keys']))
|
if (!empty($schema_changes['drop_keys']))
|
||||||
@@ -350,6 +362,9 @@ class phpbb_db_tools
|
|||||||
foreach ($schema_changes['drop_columns'] as $table => $columns)
|
foreach ($schema_changes['drop_columns'] as $table => $columns)
|
||||||
{
|
{
|
||||||
foreach ($columns as $column)
|
foreach ($columns as $column)
|
||||||
|
{
|
||||||
|
// Only remove the column if it exists...
|
||||||
|
if ($this->sql_column_exists($table, $column))
|
||||||
{
|
{
|
||||||
$result = $this->sql_column_remove($table, $column);
|
$result = $this->sql_column_remove($table, $column);
|
||||||
|
|
||||||
@@ -360,6 +375,7 @@ class phpbb_db_tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add primary keys?
|
// Add primary keys?
|
||||||
if (!empty($schema_changes['add_primary_keys']))
|
if (!empty($schema_changes['add_primary_keys']))
|
||||||
@@ -399,7 +415,7 @@ class phpbb_db_tools
|
|||||||
{
|
{
|
||||||
foreach ($index_array as $index_name => $column)
|
foreach ($index_array as $index_name => $column)
|
||||||
{
|
{
|
||||||
$result = $this->sql_create_unique_index($table, $index_name, $column);
|
$result = $this->sql_create_index($table, $index_name, $column);
|
||||||
|
|
||||||
if ($this->return_statements)
|
if ($this->return_statements)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user