From 764e41685beb8a42c5862b615ea8fe87a10a3869 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Wed, 26 Nov 2008 10:53:00 +0100 Subject: [PATCH] fix migration to fill the updated_at column. The rss feeds need a filled column. Fixes #794 --- db/migrate/043_add_updated_at_to_todos.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/db/migrate/043_add_updated_at_to_todos.rb b/db/migrate/043_add_updated_at_to_todos.rb index 992f2a92..ec14720a 100644 --- a/db/migrate/043_add_updated_at_to_todos.rb +++ b/db/migrate/043_add_updated_at_to_todos.rb @@ -1,8 +1,10 @@ class AddUpdatedAtToTodos < ActiveRecord::Migration def self.up add_column :todos, :updated_at, :timestamp - end - def self.down - remove_column :todos, :updated_at - end - end \ No newline at end of file + execute 'update todos set updated_at = created_at where completed_at IS NULL' + execute 'update todos set updated_at = completed_at where NOT completed_at IS NULL' + end + def self.down + remove_column :todos, :updated_at + end +end