lib/acts_as_versioned.rb
def create_versioned_table(create_table_options = {})
            # create version column in main table if it does not exist
            if !self.content_columns.find { |c| %w(version lock_version).include? c.name }
              self.connection.add_column table_name, :version, :integer
            end

            self.connection.create_table(versioned_table_name, create_table_options) do |t|
              t.column versioned_foreign_key, :integer
              t.column :version, :integer
              t.column :updated_attributes, :text
            end

            updated_col = nil
            self.versioned_columns.each do |col| 
              updated_col = col if !updated_col && %(updated_at updated_on).include?(col.name)
              self.connection.add_column versioned_table_name, col.name, col.type, 
                :limit     => col.limit, 
                :default   => col.default,
                :scale     => col.scale,
                :precision => col.precision
            end

            if type_col = self.columns_hash[inheritance_column]
              self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type, 
                :limit     => type_col.limit, 
                :default   => type_col.default,
                :scale     => type_col.scale,
                :precision => type_col.precision
            end

            if updated_col.nil?
              self.connection.add_column versioned_table_name, :updated_at, :timestamp
            end
          end
# Rake migration task to create the versioned table using options passed to acts_as_versioned
Rake migration task to create the versioned table using options passed to acts_as_versioned
Rake migration task to create the versioned table using options passed to acts_as_versioned
def create_versioned_table(create_table_options = {})
            if !self.content_columns.find { |c| %w(version lock_version).include? c.name }
              self.connection.add_column table_name, :version, :integer
            end
            self.connection.create_table(versioned_table_name, create_table_options) do |t|
              t.column versioned_foreign_key, :integer
              t.column :version, :integer
              t.column :updated_attributes, :text
            end
            updated_col = nil
            self.versioned_columns.each do |col| 
              updated_col = col if !updated_col && %(updated_at updated_on).include?(col.name)
              self.connection.add_column versioned_table_name, col.name, col.type, 
                :limit     => col.limit, 
                :default   => col.default,
                :scale     => col.scale,
                :precision => col.precision
            end
            if type_col = self.columns_hash[inheritance_column]
              self.connection.add_column versioned_table_name, versioned_inheritance_column, type_col.type, 
                :limit     => type_col.limit, 
                :default   => type_col.default,
                :scale     => type_col.scale,
                :precision => type_col.precision
            end
            if updated_col.nil?
              self.connection.add_column versioned_table_name, :updated_at, :timestamp
            end
          end
def create_versioned_table ( create_table_options = { } ) if ! self . content_columns . find { | c | %w( version lock_version ) . include? c . name } self . connection . add_column table_name , :version , :integer end self . connection . create_table ( versioned_table_name , create_table_options ) do | t | t . column versioned_foreign_key , :integer t . column :version , :integer t . column :updated_attributes , :text end updated_col = nil self . versioned_columns . each do | col | updated_col = col if ! updated_col && %(updated_at updated_on) . include? ( col . name ) self . connection . add_column versioned_table_name , col . name , col . type , :limit => col . limit , :default => col . default , :scale => col . scale , :precision => col . precision end if type_col = self . columns_hash [ inheritance_column ] self . connection . add_column versioned_table_name , versioned_inheritance_column , type_col . type , :limit => type_col . limit , :default => type_col . default , :scale => type_col . scale , :precision => type_col . precision end if updated_col . nil? self . connection . add_column versioned_table_name , :updated_at , :timestamp end end
Rake migration task to create the versioned table using options passed to acts_as_versioned
Rake migration task to create the versioned table using options passed to acts_as_versioned
# create version column in main table if it does not exist
create_table_options