Method: Sequel::Database#create_table

Defined in:
lib/sequel/database/schema_methods.rb

#create_table(name, options = {}, &block) ⇒ Object

Creates a table with the columns given in the provided block:

DB.create_table :posts do
  primary_key :id
  column :title, :text
  column :content, :text
  index :title
end

See Schema::Generator.



58
59
60
61
# File 'lib/sequel/database/schema_methods.rb', line 58

def create_table(name, options={}, &block)
  options = {:generator=>options} if options.is_a?(Schema::Generator)
  create_table_sql_list(name, *((options[:generator] || Schema::Generator.new(self, &block)).create_info << options)).flatten.each {|sql| execute_ddl(sql)}
end