From 6f689f2fa872f507527c10fa9b44cdbb96ebd3e0 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Thu, 3 Nov 2011 16:47:32 +0000 Subject: Fixed everything up to use EpochTime everywhere instead of regular Times. Datamapper can't handle timezones. --- lib/mauve/server.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/mauve/server.rb') diff --git a/lib/mauve/server.rb b/lib/mauve/server.rb index 41a76dc..233695d 100644 --- a/lib/mauve/server.rb +++ b/lib/mauve/server.rb @@ -108,14 +108,25 @@ module Mauve # # Update any tables. # - Mauve.constants.each do |c| + Mauve.constants.each do |c| next if %w(AlertEarliestDate).include?(c) m = Mauve.const_get(c) - m.auto_upgrade! if m.respond_to?("auto_upgrade!") + next unless m.respond_to?("auto_upgrade!") + m.auto_upgrade! # # Don't want to use automigrate, since this trashes the tables. # # m.auto_migrate! if m.respond_to?("auto_migrate!") + # + # + m.properties.each do |prop| + next unless prop.is_a?(DataMapper::Property::EpochTime) + logger.info("Updating #{c}.#{prop.name}") + statement = "UPDATE mauve_#{DataMapper::Inflector.tableize(c)} SET #{prop.name} = strftime(\"%s\",#{prop.name}) WHERE #{prop.name} LIKE \"%-%-%\";" + DataMapper.repository(:default).adapter.execute("BEGIN TRANSACTION;") + DataMapper.repository(:default).adapter.execute(statement) + DataMapper.repository(:default).adapter.execute("COMMIT TRANSACTION;") + end end AlertHistory.migrate! -- cgit v1.2.1