Your model code says "I have a foreign key to myself, and it is always
required", which might make a tree structure hard to derive! Change the
'parent_folder' member definition to look like so:
parent_folder = models.ForeignKey('self', null=True, blank=True)
Also, instead of setting parent_folder_id to be 0 (which surely does not
refer to a valid Folder model instance?), you should either not set it
at all or set it to None.
The reason it worked before, is that MyISAM has no referential
integrity, where as InnoDB does, so when you try to insert that row, it
now refuses because there is no such row in the folder_folder table with
the id 0. MyISAM would never check that, so your code worked.
Cheers
Tom