Module: ActiveRecord::ConnectionAdapters::SchemaStatements
- Defined in:
- lib/active_record/column_metadata/write.rb
Instance Method Summary collapse
-
#create_table(table_name, options = {}) {|table_definition| ... } ⇒ Object
works only with databases that support comments on columns.
Instance Method Details
#create_table(table_name, options = {}) {|table_definition| ... } ⇒ Object
works only with databases that support comments on columns
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_record/column_metadata/write.rb', line 28 def create_table(table_name,={},&block) table_definition = TableDefinition.new(self) table_definition.primary_key([:primary_key] || Base.get_primary_key(table_name)) unless [:id] == false yield table_definition if block_given? if [:force] && table_exists?(table_name) drop_table(table_name, ) end create_sql = "CREATE#{' TEMPORARY' if [:temporary]} TABLE " create_sql << "#{quote_table_name(table_name)} (" create_sql << table_definition.to_sql create_sql << ") #{[: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 |