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)
Line 6: Line 6:
 
==Check if latest Migration is installed==
 
==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:
 
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:
<php>phpbb_db_migrator->migration_state(migration name (e.g. 'phpbb_db_migration_data_30x_3_0_11'))</php>
+
<php>phpbb_db_migrator->migration_state(migration name (e.g. '\phpbb\db\migration\data\v30x\release_3_0_11'))</php>
 
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).<br />
 
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).<br />
 
<br />
 
<br />

Revision as of 20:40, 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, you can call the following function:

phpbb_extension_manager->handle_migrations($extension_name'enable');


Any new migration files included in the migrations/ directory in your extension will then be automatically installed.