Sha256: e40e21450eb681af5b2e4870c41efe5028bcd16d2bd09b779229c2b38bc450a7

Contents?: true

Size: 750 Bytes

Versions: 27

Compression:

Stored size: 750 Bytes

Contents

class AddSortableVersionToPuppetModules < ActiveRecord::Migration
  class PuppetModule < ActiveRecord::Base
    self.table_name = "katello_puppet_modules"
  end

  # copied from Util::Package
  def sortable_version(version)
    return "" if version.blank?
    pieces = version.scan(/([A-Za-z]+|\d+)/).flatten.map do |chunk|
      chunk =~ /\d+/ ? "#{"%02d" % chunk.length}-#{chunk}" : "$#{chunk}"
    end
    pieces.join(".")
  end

  def up
    add_column :katello_puppet_modules, :sortable_version, :string

    Katello::PuppetModule.find_each do |puppet_mod|
      puppet_mod.update_attribute(:sortable_version, sortable_version(puppet_mod.version))
    end
  end

  def down
    remove_column :katello_puppet_modules, :sortable_version
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
katello-3.4.5 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.4 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.0.2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.0.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.0.rc2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.4.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.1.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.0.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.0.rc2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.0.rc1.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.3.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.2.1.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.2.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.2.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb