Permalink
Browse files

🐞 Fix the hexes that have been added to all slugs

  • Loading branch information...
adamdawkins committed Feb 8, 2019
1 parent 5fc6ce2 commit 5e22176d54f4d104cca3bd5bf7b54e7642b8a2ed
Showing with 15 additions and 1 deletion.
  1. +14 βˆ’0 db/data/20190208234452_fix_hex_slugs.rb
  2. +1 βˆ’1 db/data_schema.rb
@@ -0,0 +1,14 @@
class FixHexSlugs < ActiveRecord::Migration[5.2]
def up
starting_hex = /^[a-f0-9]{8}-/
posts_with_bad_slugs = Post.all.select {|p| p.slug.match(starting_hex) }
posts_with_bad_slugs.map do |post|
post.slug = nil
post.save
end
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
@@ -1,2 +1,2 @@
# encoding: UTF-8
DataMigrate::Data.define(version: 20190122000411)
DataMigrate::Data.define(version: 20190208234452)

0 comments on commit 5e22176

Please sign in to comment.