This worked, but is there a cleaner solution?

  PAGE_SCHEMA = lambda{
    primary_key :id
    boolean :active, :default => true
    text    :text
    integer :version
  }

  class Page < Sequel::Model(:page)
    set_schema do
      self.instance_eval &PAGE_SCHEMA
      text    :title, :unique => true, :null => false
    end
  end

  class OldPage < Sequel::Model(:old_page)
    set_schema do
      self.instance_eval &PAGE_SCHEMA
      text    :title, :unique => false, :null => false
    end
  end

OldPage is allowed to have multiple entries with the same title
(backups of the current page), whereas Page should not.

  Aman Gupta

On Nov 26, 6:10 pm, Aman Gupta <[EMAIL PROTECTED]> wrote:
> Given:
>
>   class Page < Sequel::Model(:page)
>     set_schema do
>       primary_key :id
>       text    :title, :unique => true, :null => false
>       boolean :active, :default => true
>       text    :text
>       integer :version
>     end
>   end
>
> How can I create another table with the same schema? Or provide the
> same schema to another model? Page.schema returns a
> Sequel::Schema::Generator but I'm not sure how to use it.
>
>   Aman Gupta
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to