[LRUG] Conditionally built SQL suitable for Active Record/Rails?

Graham Ashton graham at effectif.com
Wed Mar 2 03:14:19 PST 2016


On Tue, 1 Mar 2016, at 12:00 AM, gvim wrote:
> 
> The database works fine within the Perl app as far as foreign keys and 
> normalisation are concerned. I'm just wondering whether shoe-horning the 
> SQL into Active Record is going to be more pain than it's worth.

Sorry, I hadn’t realised that was what you meant. I think if I was in your shoes, the first question would be how much value there is to be had in doing a lot more work on the app. If there’s a lot of work to do on it, it’s a question of whether a week or so of porting would pay off, in terms of time saved.

I’m reminded of my favourite XKCD comic: https://xkcd.com/1205

I’d investigate with a spike to try and improve on my “a week or so” estimate.

You can define primary keys and table names in AR models, so I’d start by defining those in a few models and seeing whether I could reproduce the app’s main queries by chaining a few ActiveRecord methods together in a console. I like Glenn’s Sequel suggestion too, but I’ve never sat down to learn it properly.

I think I’d probably aim to refactor the database schema to suit the ORM at some point, but maybe that could wait until after you’d got something up and running.

Cheers,
Graham


-- 
Graham Ashton (Founder, Agile Planner)
https://www.agileplannerapp.com | @grahamashton | @agileplanner



More information about the Chat mailing list