Sha256: f9ef5fae39b30fda5eb90c33cfdcb8609dfcb849b12c2eea2d689cc1c95150f6
Contents?: true
Size: 975 Bytes
Versions: 1
Compression:
Stored size: 975 Bytes
Contents
module Sequel class Model def self.set_schema(name = nil, &block) name ? set_dataset(db[name]) : name = table_name @schema = Schema::Generator.new(db, name, &block) if @schema.primary_key_name set_primary_key @schema.primary_key_name end end def self.schema @schema || ((superclass != Model) && (superclass.schema)) end def self.table_name dataset.opts[:from].first end def self.table_exists? db.table_exists?(table_name) end def self.create_table db.create_table_sql_list(*schema.create_info).each {|s| db << s} end def self.drop_table db.execute db.drop_table_sql(table_name) end def self.create_table! drop_table if table_exists? create_table end def self.recreate_table warn "Model.recreate_table is deprecated. Please use Model.create_table! instead." create_table! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sequel-0.2.1.1 | lib/sequel/model/schema.rb |