Created
July 24, 2013 05:23
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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