You\'ve decided to make the switch to Drupal. Fantastic! Only one problem: you have to figure out how to move your content from the old database to Drupal. Although there are many import/export modules available it\'s sometimes good to know what\'s happening behind the scenes. This session will walk you through my adventures of porting community Web sites into Drupal.
The talk will include:
* exporting usable data from your old site;
* using CCK to create the right home for your new content;
* using existing import modules (specifically: import html, node import and user import); and
* importing content \"by hand\" using MySQL command line magic.
We will also touch on some of the headaches I ran into in keeping data synchronized on very active community sites during the development phase.
This session is perfect for people who are preparing to migrate their Web site to Drupal and also people who are new to database management but want to know more about how things work behind the scenes. Of course if you\'re already a pro at data migration, please bring your stories and suggestions!
7. What does it mean to move?
1. Assessing the databases
2. The Export
3. Preparing Drupal for the new content (CCK)
4. Import modules
5. Importing content “by hand”
9. examine your database
what is the db software?
is there a tool to export content?
what formats can you export content to?
how is your content stored in the database?
do you need to move user accounts as well?
10. examine drupal’s db
what content type(s) are you using?
what are the tables you need to place content into?
17. export tools
every database has its own export tool
if you are exporting from MySQL use mysqldump
export to CSV where possible
(comma separated values)
18. exporting content: the dump
http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
You can also use PHPMyAdmin if it’s installed!
MySQL to MySQL
ejhogbin@bilbo:~$ mysqldump u root p [dbname]
> oldsite.sql
MySQL to CSV (local machine only)
ejhogbin@bilbo:~$ mysqldump u root p
fieldsterminatedby=,
tab=[outputdirectory]
tables [dbname] [tablename] > table.txt
Import into MySQL
ejhogbin@bilbo:~$ mysql u root p [newdatabase]
< oldsite.sql
23. import_html
modules: path, import_html
in Ubuntu: sudo aptget install php5xsl
(yes, even though it says XML support is enabled in the phpinfo() test file)
review the settings (keep the defaults)
copy the site to a local directory
(use wget to generate a flat site if necessary)
proceed with the import
set the path to the local directory where your static site lives
check “more settings” to set the user and default settings for each node
play with XSL template file if necessary (and you feel like an XML pro)
click “next” and choose the files to import
click import
check for errors
enjoy your imported content
35. importing plain vanilla content
1. import the data into temporary tables
2. using the insert/select command copy the data into
node and node_revisions
3. update the sequences table to show the next nid
38. insert the body/description into
node_revisions
mysql> insert ignore
node_revisions (nid, vid, uid, title,
body, timestamp, format)
select tmpdata.nid, tmpdata.nid,
tmpdata.uid, tmpdata.pagetitle,
tmpdata.pagecontent,
unix_timestamp(now()), 1
from tmpdata;
39. update sequences (v5)
mysql> select nid from node
order by nid DESC limit 1;
++
| nid |
++
| 18325 |
++
mysql> update sequences
set id = 18325
where name = “node_nid”;
mysql> update sequences
set id = 18325
where name = “node_revisions_vid”;
40. SRSLY! Do not forget!
Bad things happen when you
fail to update sequences.
photo by: croma
41. importing special content
1. import the data into temporary tables
2. using the insert/select command copy the data into
node and node_revisions
3. copy special content into CCK tables
4. update the sequences table to show the next nid