Sha256: c48ce9e3ba23128e243e1316b8cc6fdce09b2631f02972bde1b20fe9225979d2

Contents?: true

Size: 754 Bytes

Versions: 105

Compression:

Stored size: 754 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

    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

105 entries across 105 versions & 1 rubygems

Version Path
katello-3.18.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.18.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.17.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.18.0.rc2.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.18.0.rc2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.17.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.18.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.17.0.rc2.2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.17.0.rc2.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.1.2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.1.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.17.0.rc2 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.17.0.rc1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.0 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.0.rc5.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.0.rc5 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.16.0.rc4.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb
katello-3.15.3.1 db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb