Development Wiki

Migrations/Getting Started

From phpBB Development Wiki

< Migrations
Revision as of 01:43, 13 January 2013 by Exreaction (Talk | contribs)

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!

Where do I create the Migration file?

Extension Author

Create a directory in ext/your_extension_name/ called migrations. All of your Migration files should be in this directory.

Modification Author

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 includes/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:

Extension Author
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.

Migration Dependencies

Before you start making Migration files that you want to use, you should understand Migration dependencies and how they work.

Schema Changes

If you need to make any schema changes (Creating/Changing/Removing Tables/Columns/Indexes) you should read the following page.
Migrations/Schema Changes

Data Changes

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.
Migrations/Data Changes