B'more on Rails Message Board › Switching a project from SQLite3 to MySQL or PostgreSQL

Switching a project from SQLite3 to MySQL or PostgreSQL

Shahbaz J.
user 11700668
Columbia, MD
Post #: 1
Folks,

I just joined the group and I hope to get to know you all over time. I had a question that just came up yesterday to which I haven't found a solution yet. I've got an existing rails project (2.3.x) which I started with a SQLite3 database figuring I'd play with it see just how far I could take it. Turns out even at an early stage (4-5 models and associated controllers/views) it's become fairly functional and is in use. Development continues, of course, but based on its performance under mod_passenger I believe the SQLite3 database is becoming a bottleneck when it comes to 2 or more concurrent requests.

I'd like to upgrade to PostgreSQL or even MySQL but am not sure how to transfer all my existing data from the SQLite3 database to the new one. One thought was to setup the new database as a test database in database.yml and then attempt to clone the database from production to test using the db:test:clone rake task. I'd be relying on the database-agnostic nature of schema.rb and the assumption that this extends to any work done by the db:* set of tasks.

Any ideas?
Thanks!
Shahbaz
George A.
user 3366585
Baltimore, MD
Post #: 14
Shahbaz,

(You're the same Shahbaz from simplifyMD, no?)

I think you're looking for Adam Wiggins' YAML DB Plugin (http://www.railslodge...­.

You could set up the new DB as the "test" DB, then use 'rake db:test:clone' but that would only get you the schema, not the data. That's essentially the same as 'RAILS_ENV=test rake db:schema:load'. However, it may be easier to follow the example on the YAML DB link (above). Easy enough.

You may have to tweak some code if you resorted to writing SQL in your code. Maybe not, but keep an eye out for it. Hopefully you have a decent test suite you can run post-migration to ensure everything's in order.

If you have more questions fire away, on or off list.

Good luck,

/g

--

George Anderson

BenevolentCode LLC
Shahbaz J.
user 11700668
Columbia, MD
Post #: 2
George,

Good to see you here! Yes, the very same Shahbaz. I just clicked on the link: "database-independent format for dumping and restoring data" looks like exactly what I need. I've been avoiding SQL in the code to allow for maximum portability so hopefully things will work out.

Thanks for the tip!
S
Powered by mvnForum

Our Sponsors

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy