diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-13 13:21:01 -0600 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-01-13 13:21:01 -0600 |
commit | 000b8fefd2788c7f9f6aa6efc1d93658a00e48bd (patch) | |
tree | efad671210e9a99f27fa9a09fc2574277e8acc1f /phpBB/includes/db | |
parent | 26c16559c3496f5496ad6e83e55c40f03edda5bd (diff) | |
download | forums-000b8fefd2788c7f9f6aa6efc1d93658a00e48bd.tar forums-000b8fefd2788c7f9f6aa6efc1d93658a00e48bd.tar.gz forums-000b8fefd2788c7f9f6aa6efc1d93658a00e48bd.tar.bz2 forums-000b8fefd2788c7f9f6aa6efc1d93658a00e48bd.tar.xz forums-000b8fefd2788c7f9f6aa6efc1d93658a00e48bd.zip |
[feature/migrations] Function to populate the migrations table (for install)
PHPBB3-9737
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r-- | phpBB/includes/db/migrator.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index b56da95b1a..69a5a4dd9c 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -125,6 +125,42 @@ class phpbb_db_migrator } /** + * This function adds all migrations in a specified directory to the migrations table + * + * THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER. + * THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE! + * + * @param string $path Path to migration data files + * @param bool $recursive Set to true to also load data files from subdirectories + * @return null + */ + public function populate_migrations_from_directory($path, $recursive = true) + { + $existing_migrations = $this->migrations; + + $this->migrations = array(); + $this->load_migrations($path, true, $recursive); + + foreach ($this->migrations as $name) + { + if ($this->migration_state($name) === false) + { + $state = array( + 'migration_depends_on' => $name::depends_on(), + 'migration_schema_done' => true, + 'migration_data_done' => true, + 'migration_data_state' => '', + 'migration_start_time' => time(), + 'migration_end_time' => time(), + ); + $this->insert_migration($name, $state); + } + } + + $this->migrations = $existing_migrations; + } + + /** * Load migration data files from a directory * * Migration data files loaded with this function MUST contain |