def setup
begin
- DatabaseVersion.migrate_and_start unless DatabaseVersion.uptodate?
+ if !DatabaseVersion.upgradable?
+ raise "Upgrade is not supported. Please use a production-ready database."
+ end
+
+ DatabaseVersion.upgrade_and_start unless DatabaseVersion.uptodate?
hash={:status => 'ok'}
respond_to do |format|
format.json{ render :json => jsonp(hash) }
def index
if DatabaseVersion.uptodate?
- render :template => "setup/index"
+ render :template => 'setup/index'
elsif ActiveRecord::Base.connected?
- render :template => "setup/form", :layout => 'nonav'
+ render :template => (DatabaseVersion.upgradable? ? 'setup/form' : 'setup/not_upgradable'), :layout => 'nonav'
else
- render :template => "setup/dbdown", :layout => 'nonav'
+ render :template => 'setup/dbdown', :layout => 'nonav'
end
end
def maintenance
- render :template => "setup/maintenance", :layout => 'nonav'
+ render :template => 'setup/maintenance', :layout => 'nonav'
end
def setup_database
- # do not forget that this code is also in /api/server/setup (see api/server_controller.rb)
- DatabaseVersion.migrate_and_start unless DatabaseVersion.uptodate?
- redirect_to home_path
+ if !DatabaseVersion.upgradable?
+ render :text => 'Upgrade is not supported. Please use a production-ready database.', :status => 500
+ else
+ # do not forget that this code is also in /api/server/setup (see api/server_controller.rb)
+ DatabaseVersion.upgrade_and_start unless DatabaseVersion.uptodate?
+ redirect_to home_path
+ end
end
end
$uptodate
end
- def self.migrate_and_start
+ def self.upgrade_and_start
ActiveRecord::Migrator.migrate(migrations_path)
Java::OrgSonarServerPlatform::Platform.getInstance().start()
load_plugin_webservices()
def self.automatic_setup
if current_version<=0
try_restore_structure_dump() if use_structure_dump?
- migrate_and_start()
+ upgrade_and_start()
end
if uptodate?
load_plugin_webservices()
+ else
+ puts "Server must be upgraded. Please browse /setup"
end
uptodate?
end
# default value is true
::Java::OrgSonarServerUi::JRubyFacade.getInstance().getConfigurationValue('sonar.useStructureDump')!='false'
end
+
+ def self.upgradable?
+ dialect()!='derby'
+ end
end
\ No newline at end of file