I recently imported 3000+ MovableType posts and 14,000+ comments into Drupal with the Table Wizard and Migrate modules. Now, unfortunately I need to change the input format for all posts to Textile (format ID #4 in my system.)

I've looked for modules that would let me do it but I think it's an obscure enough task that nobody's written one.

Is there a more efficient way than hand-editing to do the conversion?

Just a pointer to the right table(s) in the database would be enough since I'm very familiar with SQL, but if there's a proper way to do it with PHP and Drupal hooks (which I'm not so familiar) I'd use that instead. (I'll be backing up the database early and often either way.)

Thanks.

Comments

vm’s picture

node_revisions table format row I think.

davidinnes’s picture

I don't think I'd have ever looked for it there. It worked perfectly. Thanks, VeryMisunderstood!

---

Example queries:

To backup the database first

mysqldump --add-drop-table -u username -p mydatabasename > mydatabasename_backup.sql

To convert nodes with the default HMTL (format #2) to custom filter Textile on my site (format #4)

UPDATE node_revisions SET format = 4 WHERE format = 2

To convert all nodes on my site to Textile (I was sure that's what I wanted to do, plus I had a backup)

UPDATE node_revisions SET format = 4

keva’s picture

thanks to you both. I'm just figuring out SQL, so your detailed reply with instructions on how to make it work helped immensely. Worked like a charm.

deselse’s picture

Glad that i found the solution here. You are just one step ahead of me asking the question. Nice solution though.

brenda003’s picture

2dareis2do’s picture

Just what I was looking for. Not sure it actually works though.

asb’s picture

The 'formats_updater' module works fine.

But unfortunately it is only available for D6.

sam6’s picture

For Drupal 7, the syntax is:

UPDATE `field_data_body` SET `body_format` = 'markdown'

if one wants to change to markdown.

For the name of other available formats, just browse the table field_data_body and look at the body_format field.

or

UPDATE `field_data_body` SET `body_format` = 'markdown' WHERE format = 'full html'

elBradford’s picture

Is there any way to do this while also running all the node bodies through the current input filter? We are converting a bunch of wiki nodes which are wiki text to html.

doublejosh’s picture

Make sure to check far and wide when updating formats.
This query will get you all the format columns for your content so you can be sure you've been thorough.
select TABLE_NAME, COLUMN_NAME from COLUMNS where TABLE_SCHEMA = 'your_database_name' and COLUMN_NAME like '%format%';

This will include some noise. Mine boiled down to this (with lots of fields)...

block_custom.format
field_data_body.body_format
field_data_comment_body.comment_body_format
field_data_field_X.field_X_format
...
field_revision_body.body_format
field_revision_comment_body.comment_body_format
field_revision_field_X.field_X_format
...
i18n_string.format
taxonomy_term_data.format
webform.confirmation_format
hockey2112’s picture

UPDATE `field_data_body` SET `body_format` = 'markdown'

This worked well for me, but I had to clear cache. Thanks!