aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2014-02-05 10:00:01 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2014-02-05 10:00:01 -0600
commitbe28445b66c8c74f92a50b086fd6b472ecaa963b (patch)
tree92b6e35a2029861fcdd408ca0acce7a5a57359c1 /phpBB
parent38eb6b0e135293d51cc100937a6072b32e214c34 (diff)
downloadforums-be28445b66c8c74f92a50b086fd6b472ecaa963b.tar
forums-be28445b66c8c74f92a50b086fd6b472ecaa963b.tar.gz
forums-be28445b66c8c74f92a50b086fd6b472ecaa963b.tar.bz2
forums-be28445b66c8c74f92a50b086fd6b472ecaa963b.tar.xz
forums-be28445b66c8c74f92a50b086fd6b472ecaa963b.zip
[ticket/11880] migration helper file
PHPBB3-11880
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/phpbb/db/migration/helper.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/phpBB/phpbb/db/migration/helper.php b/phpBB/phpbb/db/migration/helper.php
new file mode 100644
index 0000000000..28a6a56511
--- /dev/null
+++ b/phpBB/phpbb/db/migration/helper.php
@@ -0,0 +1,82 @@
+<?php
+/**
+*
+* @package db
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+namespace phpbb\db\migration;
+
+/**
+* The migrator is responsible for applying new migrations in the correct order.
+*
+* @package db
+*/
+class helper
+{
+ /**
+ * Get the schema steps from an array of schema changes
+ *
+ * This splits up $schema_changes into individual changes so that the
+ * changes can be chunked
+ *
+ * @param array $schema_changes from migration
+ * @return array
+ */
+ public function get_schema_steps($schema_changes)
+ {
+ $steps = array();
+
+ // Nested level of data (only supports 1/2 currently)
+ $nested_level = array(
+ 'drop_tables' => 1,
+ 'add_tables' => 1,
+ 'change_columns' => 2,
+ 'add_columns' => 2,
+ 'drop_keys' => 2,
+ 'drop_columns' => 2,
+ 'add_primary_keys' => 2, // perform_schema_changes only uses one level, but second is in the function
+ 'add_unique_index' => 2,
+ 'add_index' => 2,
+ );
+
+ foreach ($nested_level as $change_type => $data_depth)
+ {
+ if (!empty($schema_changes[$change_type]))
+ {
+ foreach ($schema_changes[$change_type] as $key => $value)
+ {
+ if ($data_depth === 1)
+ {
+ $steps[] = array(
+ 'dbtools.perform_schema_changes', array(array(
+ $change_type => array(
+ $value,
+ ),
+ )),
+ );
+ }
+ else if ($data_depth === 2)
+ {
+ foreach ($value as $key2 => $value2)
+ {
+ $steps[] = array(
+ 'dbtools.perform_schema_changes', array(array(
+ $change_type => array(
+ $key => array(
+ $key2 => $value2,
+ ),
+ ),
+ )),
+ );
+ }
+ }
+ }
+ }
+ }
+
+ return $steps;
+ }
+}