"Fossies" - the Fresh Open Source Software Archive

Member "dbdiff-0.2.0/lib/dbdiff/table.rb" (20 Sep 2006, 1031 Bytes) of package /linux/privat/old/dbdiff-0.2.0.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 class DbDiff
    2   class Table
    3     attr_reader :name 
    4     attr_accessor :charset, :rows, :triggers, :keys, :foreign_keys, :columns, :collation, :engine
    5 
    6     def initialize(info = {})
    7 
    8       @rows = []
    9       @foreign_keys = []
   10       @keys = []
   11       @columns = []
   12       @triggers = []
   13 
   14       @engine = info['ENGINE']
   15       @collation = info['TABLE_COLLATION']
   16       @name = info['TABLE_NAME']
   17     end
   18 
   19     alias :table_name :name
   20 
   21     def primary_key
   22       pk = keys.find{|k| k.primary}
   23       return (pk  ? pk.columns : nil)
   24     end
   25 
   26     def ==(other)
   27       self.engine    == other.engine &&
   28       self.collation == other.collation &&
   29       self.name      == other.name
   30     end
   31 
   32     def deep_clone
   33       t = Marshal::load(Marshal.dump(self))
   34       # must clear rows out since they won't necessary be in the copy
   35     end
   36 
   37     def add_delta
   38       Delta::AddTable.new(self)
   39     end
   40 
   41     def modify_delta(new_element)
   42       Delta::ModifyTable.new(new_element)
   43     end
   44 
   45     def drop_delta
   46       Delta::DropTable.new(self)
   47     end
   48   end
   49 
   50 end