Sha256: fd2114b3c45e1b0bf6c6716a2985bb0cb99feabe6b5863883320a0983f97f9e9
Contents?: true
Size: 738 Bytes
Versions: 36
Compression:
Stored size: 738 Bytes
Contents
class AddUniquenessToPuppetclassName < ActiveRecord::Migration[5.1] class FakePuppetclass < ApplicationRecord self.table_name = 'puppetclasses' end def up names = FakePuppetclass.group(:name).count.select { |_key, value| value > 1 }.keys unless names.empty? names.each do |name| classes = FakePuppetclass.where name: name say "#{classes.count} Puppet classes with duplicate name detected: #{name}" end raise 'Please make sure there are no duplicate Puppet classes before continuing.' end remove_index :puppetclasses, :name add_index :puppetclasses, :name, unique: true end def down remove_index :puppetclasses, :name add_index :puppetclasses, :name end end
Version data entries
36 entries across 36 versions & 1 rubygems