Migrating your website to Drupal

Stella Power

on

July 25, 2009

Migrating your website to Drupal

So you've got a website using another CMS and you want to switch to Drupal? Well with the new Migrate and Table Wizard modules the whole migration process is now relatively painless! Recently I needed to migrate a website from CMS Made Simple to Drupal. Thankfully it was already using a MySQL database so I didn't have to deal with multiple database types. The table wizard and migrate modules only work with MySQL databases at present, so if your data is stored in Postgres or another database, then you first need to export it to MySQL. However the table wizard module also provides an upload delimited file tool, so you can import your content, one table at a time, without having to get to grips with MySQL syntax. Once you have your data in a MySQL database, you just need to go to admin/content/tw and click on the tables you wish to add. The table wizard module will then, using the Views module, create views of your data. One view for each table is created. The only caveat is that the tables must have just a single primary key. You may need to modify your table structure if it doesn't have this. A full listing of the views created for your views can be seen at admin/content/tw. From here you can click on the view name and see its contents. However, there is also an 'analyze' link. The analysis page allows you to browse the table structure and make notes against each column. This is incredibly useful as you're trying to figure out what data is stored where. You can also mark columns to be ignored. This will prevent the column from appearing in the view, which you may want if it doesn't contain any data worth migrating. Columns which are completely empty are automatically ignored. In addition, you can create relationships between tables at admin/content/tw/relationships. This may be necessary if related data is stored in more than one table. In Drupal for example, you would need a relationship between the node and node_revisions table. Likewise in other CMS databases, you'll encounter the same situation. To make a relationship between tables, you need to identify the keys in each which link the two. If the column you wish to join on doesn't appear in the list of keys, then you can mark it as a key on the analysis page. When you make the relationship you can choose to have the base table view automatically updated with the relationship. This means you can then edit the view and add fields you need from the related table to the view. Once you're happy you understand the source tables and data, you can then start the migration process. On admin/content/migrate/destinations you can create content sets. A content set is essentially a mapping of data in the source tables to Drupal form fields. The migrate module already supports a wide variety of content, including nodes, users and comments. It even already supports CCK fields, making this module incredibly useful. After you've created one or more content sets, you just need to go to admin/content/migrate/process, select the content sets you wish to process and click submit. This will start migrating your data into Drupal. One of the areas I worked on was the exporting of content set mappings, storing them in code and having them automatically imported for you. It's still a patch at the moment, but even though the final migration hasn't taken place yet, it has saved me so much time already. I can start with a clean Drupal installation and a newly exported source database dump and have my content sets available for processing in a matter of minutes. Please help get this patch added to the module by downloading and testing it out: http://drupal.org/node/484404 Also check out the Chaos Tools module which made the whole exportable feature possible. Finally, props to Mike Ryan and Moshe Weitzman of Cyrve for providing such awesome modules!

Share it!

This is just the write up i wanted. great timing. Thanks. In my situation i would like to have three to four tables imported to Mysql form SQL server, once i have the data in mysql database i need to query it with drupal then view it in drupal. Will this solution hold and if it holds will i need to migrate the data to drupal since all i want is to display using views.

thanks now i have somewhere to start.

You should just need the tablewizard (tw) module. No need to use the migrate module unless you want to create Drupal nodes, users, etc. The Table Wizard module will allow you to create views displaying the table content, once you have it in MySQL that is :)