Sha256: 86f749cc766d17dc76d9a2802a57b2618c16ae49028d277cf205410f7e8f529e

Contents?: true

Size: 376 Bytes

Versions: 3

Compression:

Stored size: 376 Bytes

Contents

# -*- encoding : utf-8 -*-

# rubocop:disable all

class AddIndexForPath < ActiveRecord::Migration
  def self.up
    shares = Gitdocs::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

3 entries across 3 versions & 1 rubygems

Version Path
gitdocs-0.6.2 lib/gitdocs/migration/004_add_index_for_path.rb
gitdocs-0.6.1 lib/gitdocs/migration/004_add_index_for_path.rb
gitdocs-0.6.0 lib/gitdocs/migration/004_add_index_for_path.rb