aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/db/db_tools.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-02-28 16:40:01 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-02-28 16:40:01 +0000
commite40d9c4386f2b2e1ec01ee668934808247fbaf6f (patch)
treecb0b3181cdca2f08d168ebb604539a4f4f0361e3 /phpBB/includes/db/db_tools.php
parente7fbdafd7c6f4d857e4932a41c9c7617083e4ac4 (diff)
downloadforums-e40d9c4386f2b2e1ec01ee668934808247fbaf6f.tar
forums-e40d9c4386f2b2e1ec01ee668934808247fbaf6f.tar.gz
forums-e40d9c4386f2b2e1ec01ee668934808247fbaf6f.tar.bz2
forums-e40d9c4386f2b2e1ec01ee668934808247fbaf6f.tar.xz
forums-e40d9c4386f2b2e1ec01ee668934808247fbaf6f.zip
fix creating index and add more checking to schema changes
git-svn-id: file:///svn/phpbb/trunk@9348 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db/db_tools.php')
-rw-r--r--phpBB/includes/db/db_tools.php40
1 files changed, 28 insertions, 12 deletions
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php
index b32faddb91..3eb8785bd7 100644
--- a/phpBB/includes/db/db_tools.php
+++ b/phpBB/includes/db/db_tools.php
@@ -296,7 +296,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)
{
@@ -313,15 +321,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);
}
}
}
@@ -351,11 +363,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);
+ }
}
}
}
@@ -399,7 +415,7 @@ class phpbb_db_tools
{
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)
{