# File lib/kirbybase.rb, line 2531
    def add_column(col_name, col_type, after=nil)
        raise "Do not execute this method in client/server mode!" if \
         @db.client?

        raise "Invalid column name in 'after': #{after}" unless after.nil? \
         or @field_names.include?(after)

        raise "Invalid column name in 'after': #{after}" if after == :recno

        raise "Column name cannot be recno!" if col_name == :recno
        
        raise "Column name already exists!" if @field_names.include?(
         col_name)

        # Does this new column have field extras (i.e. Index, Lookup, etc.)

        if col_type.is_a?(Hash)
            temp_type = col_type[:DataType]
        else
            temp_type = col_type
        end

        raise 'Invalid field type: %s' % temp_type unless \
         KBTable.valid_field_type?(temp_type)

        field_def = @db.build_header_field_string(col_name, col_type)

        @db.engine.add_column(self, field_def, after)

        # Need to reinitialize the table instance and associated indexes.

        @db.engine.remove_recno_index(@name)
        @db.engine.remove_indexes(@name)

        update_header_vars
        create_indexes
        create_table_class unless @db.server?
    end