The migrator component makes moving data from your old Joomla! 1.0 site to a shiny new 1.5 site very easy. You can even make it migrate data from third party components, using the so called ETL plugins (for Extract, Transform, Load). But what if the components you’re using don’t supply ETL plugins? Roll your own! You don’t have to be an expert developer — just follow these easy steps.

  1. Find out which database tables the component uses. You can usually find these by looking at phpMyAdmin, or by looking for files in the component’s /table folder.
  2. For each of these table, make a new file and give it the name of the table. Eg. if the table is called #__guestbook, make a file called guestbook.php. Keep in mind that come components might depend on tables from other components or the core, such as the user table. You’ll need to make sure you migrate those tables as well.
  3. Inside the file make a class with the name of the table, like this:
    class Guestbook_ETL extends ETLPlugin
  4. First we tell the migrator what our plugin is called:
    public function getName() {
      return 'My Guestbook Migrator Plugin';
    }
  5. Next, we need to tell the migrator what table we migrate from:
    public function getAssociatedTable() {
      return 'guestbook'; // no prefix needed
    } 
  6. Finally, we need the CREATE statement. You can get that by using SHOW CREATE TABLE jos_guestbook in your MySQL client, or by looking at the component’s XML file.
    public function getSQLPrologue(){
      return 'CREATE TABLE #__guestbook (`id` int(11) NOT NULL auto_increment, .....';
    }
  7. Install the migrator component on your old site, and use it’s upload feature to add the plugins. Activate the migration and continue as usual.
  8. Enable Legacy mode and install the component. Make sure to check the XML file, some components have a DROP TABLE statement in there. It’s also good practice to use CREATE TABLE IF NOT EXISTS statements.

This approach should work for most of the components out there. Still, this is only the tip of the iceberg. Migrator plugins are a lot more powerful than that. They allow you to rewrite the tables and the data in them, eg. for when the 1.0 and the 1.5 version of the component have a different database schema. If you want to learn more about that, you should take a look at the actual ETLPlugin class, as well as the core plugins that come with the com_migrator package.

Resources

  • Plugin without query

    how to write the same plugin without the create table query but to creates a table

  • http://www.buildasitebookmarks.com/ResourceCenter/FreeWebTools/KeywordExtractor Keyword extractor

    Easy migration. Thanks for sharing.