aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/server.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-11-03 16:48:52 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-11-03 16:48:52 +0000
commit4d6b2e47ac5b135097bc8eb7b2b1ebae65668647 (patch)
tree8f6174fafcc7c356087fc209991b89dea0c3295d /lib/mauve/server.rb
parentf93f0948e028c33694cf7f90c7d5918cbf27971c (diff)
parent6f689f2fa872f507527c10fa9b44cdbb96ebd3e0 (diff)
Merge
Diffstat (limited to 'lib/mauve/server.rb')
-rw-r--r--lib/mauve/server.rb15
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!