Sha256: e4beeb25df0d769979c9de663da320feca93636f9b1682972be14d82c446878c

Contents?: true

Size: 694 Bytes

Versions: 7

Compression:

Stored size: 694 Bytes

Contents

# This migration comes from spree (originally 20110314192118)
class RemoveTrailingSlashesInTaxonPermalinks < ActiveRecord::Migration
  def up
    taxons = select_all "SELECT * FROM taxons"
    taxons.each do |taxon|
      if taxon['permalink'] && taxon['permalink'][-1..-1] == '/'
        execute "UPDATE taxons SET permalink = '#{taxon['permalink'][0...-1]}' WHERE id = #{taxon['id']}"
      end
    end
  end

  def down
    taxons = select_all "SELECT * FROM taxons"
    taxons.each do |taxon|
      if taxon['permalink'] && taxon['permalink'][-1..-1] != '/'
        execute "UPDATE taxons SET permalink = '#{taxon['permalink'] + '/'}' WHERE id = #{taxon['id']}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
spree_mercado_pago_payment_method-0.0.2 spec/dummy/db/migrate/20121121030218_remove_trailing_slashes_in_taxon_permalinks.spree.rb
spree_mercado_pago_payment_method-0.1.1 spec/dummy/db/migrate/20121121030218_remove_trailing_slashes_in_taxon_permalinks.spree.rb
spree_mercado_pago_payment_method-0.1.0 spec/dummy/db/migrate/20121121030218_remove_trailing_slashes_in_taxon_permalinks.spree.rb
datashift_spree-0.3.0 spec/sandbox/db/migrate/20121023154437_remove_trailing_slashes_in_taxon_permalinks.spree.rb
datashift_spree-0.2.1 spec/sandbox/db/migrate/20121015151230_remove_trailing_slashes_in_taxon_permalinks.spree.rb
datashift_spree-0.2.0 spec/sandbox/db/migrate/20120925192798_remove_trailing_slashes_in_taxon_permalinks.spree.rb
datashift_spree-0.1.0 spec/sandbox/db/migrate/20120918081529_remove_trailing_slashes_in_taxon_permalinks.spree.rb