Module: ActiveRecord::Comments::ConnectionAdapters::SQLiteAdapter
- Includes:
- AbstractSQLiteAdapter
- Defined in:
- lib/active_record/comments/connection_adapters/sqlite_adapter.rb
Instance Method Summary collapse
Methods included from AbstractSQLiteAdapter
#add_column_options!, #column_for, #comment_sql, #comments_supported?, #inline_comments?, #retrieve_column_comments, #retrieve_table_comment, #set_column_comment, #set_table_comment
Instance Method Details
#create_table(table_name, options = {}) {|td| ... } ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_record/comments/connection_adapters/sqlite_adapter.rb', line 5 def create_table(table_name, = {}) td = ::ActiveRecord::ConnectionAdapters::TableDefinition.new(self) td.primary_key([:primary_key] || ActiveRecord::Base.get_primary_key(table_name.to_s.singularize)) unless [:id] == false td.comment [:comment] if .has_key?(:comment) td.base = self yield td if block_given? if [:force] && table_exists?(table_name) drop_table(table_name) end create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE " create_sql << "#{quote_table_name(table_name)}#{td.table_comment} (" create_sql << td.columns.map do |column| column.to_sql + column.comment.to_s end * ", " create_sql << ") #{options[:options]}" execute create_sql end |