Module: ActiveRecord::Comments::ConnectionAdapters::SQLite3Adapter

Includes:
AbstractSQLiteAdapter
Defined in:
lib/active_record/comments/connection_adapters/sqlite3_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

Yields:

  • (td)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_record/comments/connection_adapters/sqlite3_adapter.rb', line 5

def create_table(table_name, options = {})
  td = create_table_definition table_name, options[:temporary], options[:options]
  td.base = self

  unless options[:id] == false
    pk = options.fetch(:primary_key) {
      ActiveRecord::Base.get_primary_key table_name.to_s.singularize
    }

    td.primary_key pk, options.fetch(:id, :primary_key), options
  end
  td.comment options[:comment] if options.has_key?(:comment)

  yield td if block_given?

  if options[:force] && table_exists?(table_name)
    drop_table(table_name, options)
  end

  execute schema_creation.accept td
  td.indexes.each_pair { |c,o| add_index table_name, c, o }
end