end
def complete_with_status(hash)
- if DatabaseVersion.uptodate?
+ if DatabaseMigrationManager.instance.is_sonar_access_allowed?
hash[:status]='UP'
- elsif ActiveRecord::Base.connected?
+ elsif DatabaseMigrationManager.instance.migration_running?
+ hash[:status]='MIGRATION_RUNNING'
+ elsif DatabaseMigrationManager.instance.requires_migration?
hash[:status]='SETUP'
else
+ # migration failed or not connected to the database
hash[:status]='DOWN'
- hash[:status_msg]='Not connected to database'
+ hash[:status_msg]=DatabaseMigrationManager.instance.message
end
end
verify :method => :post, :only => [ :setup_database ], :redirect_to => { :action => :index }
def index
- if DatabaseMigrationManager.instance.requires_migration?
- if ActiveRecord::Base.connected?
- render :template => 'setup/form', :layout => 'nonav'
- else
- render :template => 'setup/dbdown', :layout => 'nonav'
- end
+ if !ActiveRecord::Base.connected?
+ render :template => 'setup/dbdown', :layout => 'nonav'
+ elsif DatabaseMigrationManager.instance.requires_migration?
+ render :template => 'setup/form', :layout => 'nonav'
elsif DatabaseMigrationManager.instance.migration_running?
render :template => 'setup/migration_running', :layout => 'nonav'
elsif DatabaseMigrationManager.instance.migration_failed?
@start_time
def initialize
- if DatabaseVersion.uptodate?
+ if !ActiveRecord::Base.connected?
+ @status = MIGRATION_FAILED
+ @message = "Not connected to database."
+ elsif DatabaseVersion.uptodate?
@status = NO_MIGRATION
@message = "Database is up-to-date, no migration needed."
else