Skip to content

Instantly share code, notes, and snippets.

@adamgotterer
Created July 24, 2013 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamgotterer/6068243 to your computer and use it in GitHub Desktop.
Save adamgotterer/6068243 to your computer and use it in GitHub Desktop.
Monkey patch for Sequel to support table inheritance in create_table. Not pretty, but functional.
module Sequel
class Database
def create_table_from_generator(name, generator, options)
sql = create_table_sql(name, generator, options)
if options.has_key? :inherits
sql = "#{ sql } INHERITS (#{ options[:inherits] })"
end
execute_ddl(sql)
end
end
end
# Usage
WH.create_table :some_table, { inherits: 'some_parent_table' } do
primary_key :some_id, name: :some_table_some_id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment