Sha256: 3f5ca820fc481e0f56106f815418378d81615abfe6fa55bee1fd99f2452205ed

Contents?: true

Size: 822 Bytes

Versions: 90

Compression:

Stored size: 822 Bytes

Contents

class AddSortableVersionToPuppetModules < ActiveRecord::Migration[4.2]
  class PuppetModule < ApplicationRecord
    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

    return unless Object.const_defined?('::Katello::PuppetModule')

    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

90 entries across 90 versions & 1 rubygems

Version Path
katello-4.14.2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.15.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.15.0.rc2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.15.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.14.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.14.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.14.0.rc3 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.14.0.rc2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.14.0.rc1.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.14.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.13.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.13.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.12.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.13.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.12.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.12.0.rc3 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.12.0.rc2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.12.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.11.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-4.11.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb