module ActiveRecord::ConnectionAdapters::SchemaStatements
Public Instance Methods
create_table(table_name,options={}) { |table_definition| ... }
click to toggle source
works only with databases that support comments on columns
# File lib/active_record/column_metadata/write.rb, line 28 def create_table(table_name,options={},&block) table_definition = TableDefinition.new(self) table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name)) unless options[:id] == false yield table_definition if block_given? if options[:force] && table_exists?(table_name) drop_table(table_name, options) end create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE " create_sql << "#{quote_table_name(table_name)} (" create_sql << table_definition.to_sql create_sql << ") #{options[:options]}" execute create_sql table_definition.comments.each{ |c| write_json_comment(table_name, c.to_a.first, c.to_a.last) } if table_definition.comments end