3.9. Migration scripts

Migration scripts are perl scripts intended on changing from an old data structure to a newer version of it per eBox module basis. That is, the old configuration stored in GConf is migrated to a new structure setting the default values for the new attributes that are stored in the new version. Their names must follow this pattern [0-9]{4}_${descriptive_name_with_underscores}, for instance 0002_add_weight_to_gateway.pl, and they must live under migration/ directory. The numbers are incremental and describe the target version, hence the previous example is a migration script between data version 1 to 2.

Migration script must contain a EBox::Migration package which inherits from EBox::MigrationBase and override runGConf where the migration gets done. The main program from the script should follow this structure:

EBox::init();
my $network = EBox::Global->modInstance('network');
my $migration = new EBox::Migration( 
				     'gconfmodule' => $network,
				     'version' => 2 
				    );
$migration->execute();
          

The constructor must have the GConf module to fetch and store the data and the data version to where the data structure will be upgrade. Afterwards, the execute should be run to do migrate the data.