diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-11-03 16:47:32 +0000 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2011-11-03 16:47:32 +0000 |
commit | 6f689f2fa872f507527c10fa9b44cdbb96ebd3e0 (patch) | |
tree | 253f15908d8bc7b7dd854001df0f5859869a1538 /lib/mauve/server.rb | |
parent | 0515cd0ecd48494058e12f96233199026133124c (diff) |
Fixed everything up to use EpochTime everywhere instead of regular Times.
Datamapper can't handle timezones.
Diffstat (limited to 'lib/mauve/server.rb')
-rw-r--r-- | lib/mauve/server.rb | 15 |
1 files changed, 13 insertions, 2 deletions
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! |