diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-05 09:14:17 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-01-05 09:14:17 +0000 |
commit | 4b4085303b3d4c970bc950206d1da0cd5cf97b1f (patch) | |
tree | 6d98923ac60f2fda98f28b797cf52d484a6032e3 /sonar-server | |
parent | 32de21d20578c3202141cd1965a8f3d53c8ba786 (diff) | |
download | sonarqube-4b4085303b3d4c970bc950206d1da0cd5cf97b1f.tar.gz sonarqube-4b4085303b3d4c970bc950206d1da0cd5cf97b1f.zip |
improve db migration to avoid deleting special snapshots (like pacbase projects)
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb index 623f1c8087f..e14e0dfa506 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/170_delete_unvalid_project_snapshots.rb @@ -24,17 +24,14 @@ class DeleteUnvalidProjectSnapshots < ActiveRecord::Migration def self.up - metric=Metric.find(:first, :conditions => ['name=?','lines']) - if metric - snapshots=select_snapshots_without_measures(metric) - delete_snapshots(snapshots) - end + snapshots=select_snapshots_without_measures + delete_snapshots(snapshots) end - def self.select_snapshots_without_measures(metric) + def self.select_snapshots_without_measures snapshots=nil say_with_time "Select project snapshots without measures..." do - snapshots=Snapshot.find_by_sql ["SELECT s.id FROM snapshots s WHERE s.scope='PRJ' and s.qualifier IN ('TRK', 'BRC') AND status='P' AND islast=? AND NOT EXISTS (select m.id from project_measures m WHERE m.snapshot_id=s.id AND m.metric_id=?)", false, metric.id] + snapshots=Snapshot.find_by_sql ["SELECT s.id FROM snapshots s WHERE s.scope='PRJ' and s.qualifier IN ('TRK', 'BRC') AND status='P' AND islast=? AND NOT EXISTS (select m.id from project_measures m WHERE m.snapshot_id=s.id)", false] end snapshots end |