module SchemaComments::ConnectionAdapters::Adapter

Public Instance Methods

column_comments(*args) click to toggle source

Mass assignment of comments in the form of a hash. Example:

column_comments(:users, {:first_name => "User's given name", :last_name => "Family name"})
column_comments(:tags , {:id => "Tag IDentifier"})
# File lib/schema_comments/connection_adapters.rb, line 32
def column_comments(*args)
  case args.length
  when 1 then
     # こっちはSchemaComments::Base::ClassMethods#columns_with_schema_commentsから呼び出されます。
    return SchemaComment.column_comments(args.first)
  when 2 then
    if args.last.is_a?(Hash)
      # マイグレーションからActiveRecord関係を経由して呼び出されます。
      table_name = args.first.to_s
      args.last.each do |col, comment|
        column_comment(table_name, col, comment) unless SchemaComments.quiet
      end
      return
    end
  end
  raise ArgumentError, "#{self.class}#column_comments accepts (tabel_name) or (tabel_name, hash_col_comment)"
end
delete_schema_comments(table_name, column_name = nil) click to toggle source
# File lib/schema_comments/connection_adapters.rb, line 60
def delete_schema_comments(table_name, column_name = nil)
  SchemaComment.destroy_of(table_name, column_name) unless SchemaComments.quiet
end
update_schema_comments_column_name(table_name, column_name, new_name) click to toggle source
# File lib/schema_comments/connection_adapters.rb, line 68
def update_schema_comments_column_name(table_name, column_name, new_name)
  SchemaComment.update_column_name(table_name, column_name, new_name) unless SchemaComments.quiet
end
update_schema_comments_table_name(table_name, new_name) click to toggle source
# File lib/schema_comments/connection_adapters.rb, line 64
def update_schema_comments_table_name(table_name, new_name)
  SchemaComment.update_table_name(table_name, new_name) unless SchemaComments.quiet
end