I’m working with a project that is transitioning from sqlite to mysql. Unfortunately the schema of individual tables has changed somewhat and a wholesale import won’t work. Are there any good tools or solutions to do this?
I’m using ruby on rails 3.0.10 currently. My best guess was going to be initiate a console session, use namespaced active record adapters to connect to both databases, and then copy all the items over in code.
(the original database is fairly small i.e. less than a few thousand rows per table)
What might be easiest is to export the Sqlite database in a format that can be loaded back in to MySQL directly, then create migrations that alter the schema as required, starting with the Sqlite structure and adjusting from there.
One tool you might try is yaml_db to dump the one database into fixture-style YAML files, and then load it back in on the other side.
Remember that your
schema.rbfile should be sufficiently database agnostic so as to allow you torake db:createwhen switching yourdatabase.ymladapter definition.You might want to create a separate environment for the previous structure by adding a new entry to
database.ymlandconfig/environmentsso you can switch back and forth without having to hack at a few different config files all the time.