rubysequelpadrinosequel-gem

Using Padrino with Sequel, Can Migrations Create Singularly Named SQL Tables?


I'm looking to build an application using the Padrino Framework with Sequel as my ORM. The problem is that I need to interface with an existing database which was created using singularly named tables. Rather than renaming the SQL tables (as other applications also use this database), would I be able to have padrino use a singular name for tables (such as "Entry" instead of "Entries")?

Thanks for your time and assistance.


Solution

  • You can define a Sequel model on a table with a singular/arbitrary name like this:

    class Entry < Sequel::Model(:entry); end

    Tried this myself in Padrino with an "Entry" table (PostgreSQL) and it works:-

    $ padrino c
    
    > e = Entry.new
     => #<Entry @values={}> 
    > e.save
     => #<Entry @values={:id=>1}> 
    > Entry.count
     => 1 
    

    Inspiration from this question on the Sequel-Talk Google Group