phpBB

Development Wiki

Difference between revisions of "Migrations/Extensions"

From phpBB Development Wiki

(Check if latest Migration is installed: Updated to the new directory structure)
(Run Updates)
Line 12: Line 12:
  
 
==Run Updates==
 
==Run Updates==
If the user has updated your extension and new migration files were added, you can call the following function:
+
If the user has updated your extension and new migration files were added, they will be automatically installed when re-enabling the extension.
<php>phpbb_extension_manager->handle_migrations($extension_name, 'enable');</php>
+
<br />
+
Any new migration files included in the migrations/ directory in your extension will then be automatically installed.
+
  
 
[[Category:Migrations]]
 
[[Category:Migrations]]

Revision as of 20:47, 26 August 2014

Using Migrations in your Extension is a very simple thing to do.

Automatically install/revert Migrations when enabled/purged

If you wish to have your Migrations installed and removed automatically when your extension is enabled and purged respectively, all you need to do is put your Migration files in ext/(your extension name)/migrations/

Check if latest Migration is installed

To check if the latest Migration is installed that is included with your extension (to, for example, make sure all updates have been applied) call the following function:

phpbb_db_migrator->migration_state(migration name (e.g'\phpbb\db\migration\data\v30x\release_3_0_11'))

If the returned value is boolean false (compare to === false), then the migration is not installed, otherwise it is at least partially installed (assuming everything went well during the install process, it should be fully installed or not installed at all).

To check if fully installed, if bool false is not returned, an array will be containing the two keys "migration_schema_done" and "migration_data_done". If both of these are true (== true) then it is fully installed.

Run Updates

If the user has updated your extension and new migration files were added, they will be automatically installed when re-enabling the extension.