mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-29 13:00:26 +02:00
add more checks to schema changes
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9349 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -533,7 +533,7 @@ class phpbb_db_tools
|
|||||||
* {KEY/INDEX NAME} => array({COLUMN NAMES}),
|
* {KEY/INDEX NAME} => array({COLUMN NAMES}),
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* For more information have a look at /develop/create_schema_files.php (only available through CVS)
|
* For more information have a look at /develop/create_schema_files.php (only available through SVN)
|
||||||
*/
|
*/
|
||||||
function perform_schema_changes($schema_changes)
|
function perform_schema_changes($schema_changes)
|
||||||
{
|
{
|
||||||
@@ -550,8 +550,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)
|
||||||
{
|
{
|
||||||
@@ -568,10 +576,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)
|
||||||
{
|
{
|
||||||
@@ -580,7 +593,6 @@ class phpbb_db_tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Remove keys?
|
// Remove keys?
|
||||||
if (!empty($schema_changes['drop_keys']))
|
if (!empty($schema_changes['drop_keys']))
|
||||||
@@ -605,6 +617,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);
|
||||||
|
|
||||||
@@ -615,6 +630,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']))
|
||||||
|
Reference in New Issue
Block a user