88: def self.migrate
89: dbdir = nil
90: $LOAD_PATH.each { |d|
91: tmp = File.join(d, "puppet/rails/database")
92: if FileTest.directory?(tmp)
93: dbdir = tmp
94: break
95: end
96: }
97:
98: raise Puppet::Error, "Could not find Puppet::Rails database dir" unless dbdir
99:
100: raise Puppet::Error, "Database has problems, can't migrate." unless ActiveRecord::Base.connection.tables.include?("resources")
101:
102: Puppet.notice "Migrating"
103:
104: begin
105: ActiveRecord::Migrator.migrate(dbdir)
106: rescue => detail
107: puts detail.backtrace if Puppet[:trace]
108: raise Puppet::Error, "Could not migrate database: #{detail}"
109: end
110: end