Permalink
Browse files

Some archived documents never had their published_at set.

- In this commit [1] we added the published_at field to documents and
set it for all existing published documents, but we neglected to set
it for archived documents (which were necessarily once published).
- This has caused problems with displaying the change history on some
policies. Rather than add conditional logic for something that should
never happen for documents published after commit [1] was deployed.

[1] fdc1d5f
  • Loading branch information...
floehopper committed Feb 2, 2012
1 parent 69d7894 commit 1f6812fd62f8ba47c48a199640f24ab6e3a5a0db
Showing with 9 additions and 1 deletion.
  1. +8 −0 db/migrate/20120202135031_set_published_at_for_archived_documents.rb
  2. +1 −1 db/schema.rb
@@ -0,0 +1,8 @@
+class SetPublishedAtForArchivedDocuments < ActiveRecord::Migration
+ def change
+ update %{
+ UPDATE documents SET documents.published_at = documents.updated_at
+ WHERE state = 'archived' AND documents.published_at IS NULL
+ }
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120201152319) do
+ActiveRecord::Schema.define(:version => 20120202135031) do
create_table "attachments", :force => true do |t|
t.string "carrierwave_file"

0 comments on commit 1f6812f

Please sign in to comment.