From 8d3436eab0deaf31bf35a633abaa0eb18e837e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20de=20Villamil?= Date: Thu, 19 Sep 2013 20:49:01 +0200 Subject: [PATCH] Adds a migration to fix buggy notes an drafts introduced by an earlier version of Publify. Issue #246. --- .../114_fixes_buggy_articles_and_notes.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 db/migrate/114_fixes_buggy_articles_and_notes.rb diff --git a/db/migrate/114_fixes_buggy_articles_and_notes.rb b/db/migrate/114_fixes_buggy_articles_and_notes.rb new file mode 100644 index 0000000000..82a2a7a217 --- /dev/null +++ b/db/migrate/114_fixes_buggy_articles_and_notes.rb @@ -0,0 +1,22 @@ +class FixesBuggyArticlesAndNotes < ActiveRecord::Migration + def self.up + say "Fixing contents permalinks, this may take some time" + + contents = Content.where("permalink is ? or permalink = ?", nil, '') + contents.each do |c| + c.set_permalink + c.save + end + + say "Fixes empty notes GUID" + notes = Note.where("guid is ? or guid = ?", nil, '') + notes.each do |n| + n.create_guid + n.save + end + end + + def self.down + say "Nothing to do here" + end +end