From phpBB Development Wiki
To get started with Migrations, we need to first create a Migration file that will hold the list of database changes.
Before we get started, first you should remember that with Migrations there is no limit to the number of Migration files. This means that you're free to create migration files as you need, whether you want to create a single file per version, per feature, or even for every change you make to the database--it is entirely up to you!
- 1 Where do I create the Migration file?
- 2 What must go in the Migration file?
- 3 What else goes in a Migration file?
Where do I create the Migration file?
Create a directory in ext/your_extension_name/ called migrations. All of your Migration files should be in this directory.
If you do not include any Extension files in your modification, you may create a directory wherever you feel it best fits. Preferably it would be a subdirectory named migrations of a directory that contains other files for your modification only (e.g. blog/migrations/, includes/gallery/migrations)
phpBB Migration files are in phpbb/db/migration/data/
You may make a file in this directory OR make a subdirectory if you plan on creating multiple Migration files for a single feature.
What must go in the Migration file?
The only absolute requirement is creating a new class that extends phpbb_db_migration
class phpbb_new_migration_class extends phpbb_db_migration
// Data for database changes will go in here!
What should the new migration class name be?
The class naming scheme must follow phpBB autoloading standards.
Autoloading Information: http://area51.phpbb.com/phpBB/viewtopic.php?f=84&t=33237
phpbb_ext_(folder name in ext)_migrations_(identifier)
Example: phpbb_ext_blog_migrations_comments for the file ext/blog/migrations/comments.php
Example: phpbb_db_migration_data_3_0_1 for includes/db/migration/data/3_0_1.php
What else goes in a Migration file?
Now you're ready to get started adding instructions so that the Migrator knows what to do when it encounters your Migration file.
Before you start making Migration files that you want to use, you should understand Migration dependencies and how they work.
If you need to make any schema changes (Creating/Changing/Removing Tables/Columns/Indexes) you should read the following page.
If you need to make data changes (Config settings, Adding/Removing Modules, Adding/Removing/Setting/Unsetting Permissions, or other custom changes) you should read the following page.
Check If Effectively Installed
The function effectively_installed() is called before installing a Migration. This allows you to transition from a previous database installer method to Migrations easily.
If it returns true, the Migration is marked as installed without applying any changes.
This function is optional, if it is not needed you do not need to create the function.