Adding a DB Migration
Here we will show you how to add a database migration
Introduction
When your extension is installed on a IceHrm installtion, you can make changs o the IceHrm database using Migrations.
Add a Simple Migration
This extension will manage tasks. So we might have to make changes to the database. For that we should add a migration. We can use the core migration classes offered by Icehrm.
Migration.php
This migration will create a table named Tasks in IceHrm database. The migration will be executed only on the first time the extension is enabled. If you are making changes to the migration you need to make sure it gets applied manually.
Execute Migration when Installing the Extension
For this, we should update the Extension.php a bit to execute the migration when the extension is activated for the first time
Update Extension Include File
tasks.php
Since the extension is already active the migration will not get executed. Because of this we need to remove it from the Modules table manually.
Now reload the page and you will be able to see the new Tasks table in your IceHrm database.
Last updated