aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-08-17 11:11:04 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-08-17 11:11:04 +0100
commitca0a64f05616d80894e3d28c8158a624edd4eb8d (patch)
treed46260020cebcf1cb1296f1d288171fd94495a89
parent8c8e5ae926e0009743fe92dccb588783640a6022 (diff)
Tidied up auto_upgrade! code
-rw-r--r--lib/mauve/server.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/mauve/server.rb b/lib/mauve/server.rb
index 27157a5..138636e 100644
--- a/lib/mauve/server.rb
+++ b/lib/mauve/server.rb
@@ -43,6 +43,11 @@ module Mauve
#
@packet_buffer = []
@notification_buffer = []
+
+ #
+ # Set up a blank config.
+ #
+ Configuration.current = Configuration.new if Mauve::Configuration.current.nil?
end
def hostname=(h)
@@ -72,17 +77,22 @@ module Mauve
@notification_buffer = []
DataMapper.setup(:default, @database)
- # DataObjects::Sqlite3.logger = Log4r::Logger.new("Mauve::DataMapper")
+ # DataMapper.logger = Log4r::Logger.new("Mauve::DataMapper")
#
# Update any tables.
#
- Alert.auto_upgrade!
- AlertChanged.auto_upgrade!
- History.auto_upgrade!
- Mauve::AlertEarliestDate.create_view!
+ 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!")
+ #
+ # Don't want to use automigrate, since this trashes the tables.
+ #
+ # m.auto_migrate! if m.respond_to?("auto_migrate!")
+ end
- Mauve::Configuration.current = Mauve::Configuration.new if Mauve::Configuration.current.nil?
+ Mauve::AlertEarliestDate.create_view!
return nil
end