Sha256: d4d38305e80872fe3b1f0833f7cc47ba4cd458749867cbdd97aa129e9a3e3858

Contents?: true

Size: 597 Bytes

Versions: 6

Compression:

Stored size: 597 Bytes

Contents

class AddCreatedAtToAllTables < ActiveRecord::Migration
    def self.up
        ActiveRecord::Base.connection.tables.each do |t|
            unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
                add_column t.to_s, :created_at, :datetime
            end
        end
    end

    def self.down
        ActiveRecord::Base.connection.tables.each do |t|
            unless ActiveRecord::Base.connection.columns(t).collect {|c| c.name}.include?("created_at")
                remove_column t.to_s, :created_at
            end
        end
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puppet-0.25.5 lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
puppet-0.25.4 lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
puppet-0.25.3 lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
puppet-0.25.2 lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
puppet-0.25.1 lib/puppet/rails/database/001_add_created_at_to_all_tables.rb
puppet-0.25.0 lib/puppet/rails/database/001_add_created_at_to_all_tables.rb