diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2009-02-28 16:40:20 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2009-02-28 16:40:20 +0000 |
commit | 88a74afa58ceffb3d80d1f23bc81050178974959 (patch) | |
tree | 32b7aa42edbba523217e33098f8c95144f6061a5 /phpBB/includes/db | |
parent | dd059c15b66b11c538e774ac09fdbaca5f5655e2 (diff) | |
download | forums-88a74afa58ceffb3d80d1f23bc81050178974959.tar forums-88a74afa58ceffb3d80d1f23bc81050178974959.tar.gz forums-88a74afa58ceffb3d80d1f23bc81050178974959.tar.bz2 forums-88a74afa58ceffb3d80d1f23bc81050178974959.tar.xz forums-88a74afa58ceffb3d80d1f23bc81050178974959.zip |
add more checks to schema changes
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9349 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r-- | phpBB/includes/db/db_tools.php | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 7b62a25f4b..1b14bd56f6 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -533,7 +533,7 @@ class phpbb_db_tools * {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) { @@ -551,7 +551,15 @@ class phpbb_db_tools { foreach ($columns as $column_name => $column_data) { - $result = $this->sql_column_change($table, $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); + } + else + { + $result = $this->sql_column_add($table, $column_name, $column_data); + } if ($this->return_statements) { @@ -568,15 +576,19 @@ class phpbb_db_tools { foreach ($columns as $column_name => $column_data) { - // Only add the column if it does not exist yet - if (!$this->sql_column_exists($table, $column_name)) + // Only add the column if it does not exist yet, else change it (to be consistent) + 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); + } - if ($this->return_statements) - { - $statements = array_merge($statements, $result); - } + if ($this->return_statements) + { + $statements = array_merge($statements, $result); } } } @@ -606,11 +618,15 @@ class phpbb_db_tools { foreach ($columns as $column) { - $result = $this->sql_column_remove($table, $column); - - if ($this->return_statements) + // Only remove the column if it exists... + if ($this->sql_column_exists($table, $column)) { - $statements = array_merge($statements, $result); + $result = $this->sql_column_remove($table, $column); + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } } } } |