Sha256: f7593ba4f9947eb0cc8926d5aab193e4bd544a1394fad5b52f1756336782d917

Contents?: true

Size: 340 Bytes

Versions: 5

Compression:

Stored size: 340 Bytes

Contents

class AddIndexForPath < ActiveRecord::Migration
  def self.up
    shares = Gitdocs::Configuration::Share.all.reduce(Hash.new { |h, k| h[k] = [] }) { |h, s| h[s.path] << s; h }
    shares.each do |path, shares|
      shares.shift
      shares.each(&:destroy) unless shares.empty?
    end
    add_index :shares, :path, unique: true
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gitdocs-0.5.0.pre6 lib/gitdocs/migration/004_add_index_for_path.rb
gitdocs-0.5.0.pre5 lib/gitdocs/migration/004_add_index_for_path.rb
gitdocs-0.5.0.pre3 lib/gitdocs/migration/004_add_index_for_path.rb
gitdocs-0.5.0.pre2 lib/gitdocs/migration/004_add_index_for_path.rb
gitdocs-0.5.0.pre1 lib/gitdocs/migration/004_add_index_for_path.rb