Commit d5337194fc2e75020e4a9558a3ae0a09921d9580
1 parent
47085886
Exists in
master
and in
1 other branch
purge old migrations
Refs #921 By now, hopefully all our users have upgraded at least up to v0.3.0 and run migrations there which would include all but one migration at this point. Users who are upgrading from an older version of Errbit should check out v0.4.0, run migrations and then continue on from there. This is the migration plan going forward and its documented in the upgrade section of the README file.
Showing
19 changed files
with
14 additions
and
351 deletions
Show diff stats
Gemfile
Gemfile.lock
... | ... | @@ -184,6 +184,11 @@ GEM |
184 | 184 | mongoid (>= 3.0.1) |
185 | 185 | rake |
186 | 186 | rspec (>= 2.14) |
187 | + mongoid_rails_migrations (1.0.1) | |
188 | + activesupport (>= 3.2.0) | |
189 | + bundler (>= 1.0.0) | |
190 | + rails (>= 3.2.0) | |
191 | + railties (>= 3.2.0) | |
187 | 192 | multi_json (1.11.2) |
188 | 193 | multi_xml (0.5.5) |
189 | 194 | multipart-post (2.0.0) |
... | ... | @@ -211,7 +216,6 @@ GEM |
211 | 216 | omniauth-oauth2 (1.3.1) |
212 | 217 | oauth2 (~> 1.0) |
213 | 218 | omniauth (~> 1.2) |
214 | - optionable (0.2.0) | |
215 | 219 | origin (2.1.1) |
216 | 220 | orm_adapter (0.5.0) |
217 | 221 | pjax_rails (0.4.0) |
... | ... | @@ -423,6 +427,7 @@ DEPENDENCIES |
423 | 427 | meta_request |
424 | 428 | mongoid (= 5.0.0.beta) |
425 | 429 | mongoid-rspec |
430 | + mongoid_rails_migrations | |
426 | 431 | omniauth-github |
427 | 432 | pjax_rails |
428 | 433 | poltergeist | ... | ... |
README.md
... | ... | @@ -195,7 +195,13 @@ rake assets:precompile |
195 | 195 | |
196 | 196 | This will ensure that your application stays up to date with any schema changes. |
197 | 197 | |
198 | -### Upgrading errbit from version 0.3 to 0.4 | |
198 | +### Upgrading errbit beyond v0.4.0 | |
199 | + | |
200 | +* You must have already run migrations at least up to v0.3.0. Check to | |
201 | + make sure you're schema version is at least 20131011155638 by running rake | |
202 | + db:version before you upgrade beyond v0.4.0 | |
203 | + | |
204 | +### Upgrading errbit from v0.3.0 to v0.4.0 | |
199 | 205 | |
200 | 206 | * All configuration is now done through the environment. See |
201 | 207 | [configuration](docs/configuration.md) | ... | ... |
db/migrate/20110422152027_move_notices_to_separate_collection.rb
... | ... | @@ -1,38 +0,0 @@ |
1 | -class MoveNoticesToSeparateCollection < Mongoid::Migration | |
2 | - def self.up | |
3 | - errs_coll = connection["errs"] | |
4 | - | |
5 | - # copy embedded Notices into a separate collection | |
6 | - errs = errs_coll.find.select(notices: 1) | |
7 | - errs.each do |err| | |
8 | - next unless err['notices'] | |
9 | - | |
10 | - # This Err was created after the Problem->Err->Notice redesign | |
11 | - next if err['app_id'].nil? or err['problem_id'] | |
12 | - | |
13 | - e = Err.find(err['_id']) | |
14 | - # disable email notifications | |
15 | - old_notify = e.app.notify_on_errs? | |
16 | - e.app.update_attribute(:notify_on_errs, false) | |
17 | - puts "Copying notices for Err #{err['_id']}" | |
18 | - err['notices'].each do |notice| | |
19 | - e.notices.create!(notice) | |
20 | - end | |
21 | - e.app.update_attribute(:notify_on_errs, old_notify) | |
22 | - errs_coll.find({ "_id" => err['_id']}).update({ "$unset" => { "notices" => 1}}) | |
23 | - end | |
24 | - ( | |
25 | - Problem.where(:environment => '') | | |
26 | - Problem.where(:environment => nil) | | |
27 | - Problem.where(:environment => {}) | |
28 | - ).each {|pr| | |
29 | - pr.update_attributes(:environment => 'old') | |
30 | - } | |
31 | - Rake::Task["errbit:db:update_notices_count"].invoke | |
32 | - Rake::Task["errbit:db:update_problem_attrs"].invoke | |
33 | - end | |
34 | - | |
35 | - def self.down | |
36 | - end | |
37 | -end | |
38 | - |
db/migrate/20110812135951_move_issue_trackers_to_sti.rb
... | ... | @@ -1,36 +0,0 @@ |
1 | -class MoveIssueTrackersToSti < Mongoid::Migration | |
2 | - def self.up | |
3 | - App.all.each do |app| | |
4 | - # Update all embedded issue trackers to use STI patterns. | |
5 | - # All issue trackers now subclass the IssueTracker model, | |
6 | - # and their class is stored in the '_type' field, which is | |
7 | - # also aliased to 'type'. | |
8 | - tracker = app.attributes['issue_tracker'] | |
9 | - if tracker && tracker['issue_tracker_type'] | |
10 | - tracker['_type'] = case tracker['issue_tracker_type'] | |
11 | - when 'lighthouseapp'; "IssueTrackers::LighthouseTracker" | |
12 | - when 'redmine'; "IssueTrackers::RedmineTracker" | |
13 | - when 'pivotal'; "IssueTrackers::PivotalLabsTracker" | |
14 | - when 'fogbugz'; "IssueTrackers::FogbugzTracker" | |
15 | - when 'mingle'; "IssueTrackers::MingleTracker" | |
16 | - else; nil | |
17 | - end | |
18 | - | |
19 | - if tracker['issue_tracker_type'] == "none" | |
20 | - App.collection.where({ _id: app.id }).update({ | |
21 | - "$unset" => { :issue_tracker => 1 } | |
22 | - }) | |
23 | - else | |
24 | - tracker.delete('issue_tracker_type') | |
25 | - App.collection.where({ _id: app.id }).update({ | |
26 | - "$set" => { :issue_tracker => tracker } | |
27 | - }) | |
28 | - end | |
29 | - end | |
30 | - end | |
31 | - end | |
32 | - | |
33 | - def self.down | |
34 | - end | |
35 | -end | |
36 | - |
db/migrate/20110905134638_link_errs_to_problems.rb
... | ... | @@ -1,33 +0,0 @@ |
1 | -class LinkErrsToProblems < Mongoid::Migration | |
2 | - def self.up | |
3 | - puts "== Migrating from Errs to Problems..." | |
4 | - | |
5 | - puts "==== Copy err.klass to notice.klass..." | |
6 | - Notice.all.each do |notice| | |
7 | - if notice.err && (klass = notice.err['klass']) | |
8 | - notice.update_attribute(:klass, klass) | |
9 | - end | |
10 | - end | |
11 | - | |
12 | - puts "==== Create a Problem for each Err..." | |
13 | - Err.all.each do |err| | |
14 | - if err['app_id'] && app = App.where(:_id => err['app_id']).first | |
15 | - err.problem = app.problems.create(:_id => err.id) | |
16 | - err.problem.resolve! if err.resolved | |
17 | - # don't bother checking err for issue link, if it ain't got one the NoMethodError | |
18 | - # is raised, else this works fine. | |
19 | - err.problem.update_attribute(:issue_link, err.issue_link) rescue NoMethodError | |
20 | - err.save | |
21 | - end | |
22 | - end | |
23 | - | |
24 | - puts "==== Updating problem cached attributes..." | |
25 | - Rake::Task["errbit:db:update_problem_attrs"].invoke | |
26 | - puts "==== Updating notice counts..." | |
27 | - Rake::Task["errbit:db:update_notices_count"].invoke | |
28 | - end | |
29 | - | |
30 | - def self.down | |
31 | - end | |
32 | -end | |
33 | - |
db/migrate/20111019163257_add_problem_comments_count.rb
db/migrate/20111102173347_cache_problem_statistics_fix.rb
... | ... | @@ -1,33 +0,0 @@ |
1 | -class CacheProblemStatisticsFix < Mongoid::Migration | |
2 | - def self.up | |
3 | - Problem.all.each do |problem| | |
4 | - messages = {} | |
5 | - hosts = {} | |
6 | - user_agents = {} | |
7 | - problem.notices.each do |notice| | |
8 | - messages = count_attribute(messages, notice.message) | |
9 | - hosts = count_attribute(hosts, notice.host) | |
10 | - user_agents = count_attribute(user_agents, notice.user_agent_string) | |
11 | - end | |
12 | - problem.update_attributes(:messages => messages, :hosts => hosts, :user_agents => user_agents) | |
13 | - end | |
14 | - end | |
15 | - | |
16 | - def self.down | |
17 | - Problem.all.each do |problem| | |
18 | - problem.update_attributes(:messages => {}, :hosts => {}, :user_agents => {}) | |
19 | - end | |
20 | - end | |
21 | - | |
22 | - private | |
23 | - def self.count_attribute(counter, value) | |
24 | - index = Digest::MD5.hexdigest(value.to_s) | |
25 | - if counter[index].nil? | |
26 | - counter[index] = {'value' => value, 'count' => 1} | |
27 | - else | |
28 | - counter[index]['count'] += 1 | |
29 | - end | |
30 | - counter | |
31 | - end | |
32 | - | |
33 | -end |
db/migrate/20120530005915_rename_klass_to_error_class.rb
... | ... | @@ -1,13 +0,0 @@ |
1 | -class RenameKlassToErrorClass < Mongoid::Migration | |
2 | - def self.up | |
3 | - [Problem, Err, Notice].each do |model| | |
4 | - model.collection.find.update({'$rename' => {'klass' => 'error_class'}}, :multi => true, :safe => true) | |
5 | - end | |
6 | - end | |
7 | - | |
8 | - def self.down | |
9 | - [Problem, Err, Notice].each do |model| | |
10 | - model.collection.find.update({'$rename' => {'error_class' => 'klass'}}, :multi => true, :safe => true) | |
11 | - end | |
12 | - end | |
13 | -end |
db/migrate/20120603112130_change_github_url_to_github_repo.rb
... | ... | @@ -1,30 +0,0 @@ |
1 | -class ChangeGithubUrlToGithubRepo < Mongoid::Migration | |
2 | - def self.normalize_github_repo(repo) | |
3 | - return if repo.blank? | |
4 | - github_host = URI.parse(Errbit::Config.github_url).host | |
5 | - github_host = Regexp.escape(github_host) | |
6 | - repo.strip! | |
7 | - repo.sub!(/(git@|https?:\/\/)#{github_host}(\/|:)/, '') | |
8 | - repo.sub!(/\.git$/, '') | |
9 | - repo | |
10 | - end | |
11 | - | |
12 | - def self.up | |
13 | - App.collection.find.update({'$rename' => {'github_url' => 'github_repo'}}, :multi => true, :safe => true) | |
14 | - App.all.each do |app| | |
15 | - normalized_repo = self.normalize_github_repo(app.attributes['github_repo']) | |
16 | - App.collection.where({ _id: app.id }).update({ | |
17 | - "$set" => { :github_repo => normalized_repo } | |
18 | - }) | |
19 | - end | |
20 | - end | |
21 | - | |
22 | - def self.down | |
23 | - App.collection.find.update({'$rename' => {'github_repo' => 'github_url'}}, :multi => true, :safe => true) | |
24 | - App.all.each do |app| | |
25 | - unless app.github_repo.include?("github.com") | |
26 | - app.update_attribute :github_url, "https://github.com/" << app.github_url | |
27 | - end | |
28 | - end | |
29 | - end | |
30 | -end |
db/migrate/20120605091105_set_issue_type_on_problems.rb
... | ... | @@ -1,12 +0,0 @@ |
1 | -class SetIssueTypeOnProblems < Mongoid::Migration | |
2 | - def self.up | |
3 | - Problem.all.each do |p| | |
4 | - if p.issue_link.present? && p.app.issue_tracker_configured? | |
5 | - p.update_attribute :issue_type, p.app.issue_tracker.label | |
6 | - end | |
7 | - end | |
8 | - end | |
9 | - | |
10 | - def self.down | |
11 | - end | |
12 | -end |
db/migrate/20120822195841_set_first_notice_at_on_problems.rb
... | ... | @@ -1,10 +0,0 @@ |
1 | -class SetFirstNoticeAtOnProblems < Mongoid::Migration | |
2 | - def self.up | |
3 | - Problem.all.each do |problem| | |
4 | - problem.update_attribute :first_notice_at, problem.notices.order_by([:created_at, :asc]).first.try(:created_at) | |
5 | - end | |
6 | - end | |
7 | - | |
8 | - def self.down | |
9 | - end | |
10 | -end |
db/migrate/20120829034812_ensure_that_problems_last_notice_at_is_not_nil.rb
... | ... | @@ -1,23 +0,0 @@ |
1 | -class EnsureThatProblemsLastNoticeAtIsNotNil < Mongoid::Migration | |
2 | - def self.up | |
3 | - Problem.where("$or" => [{:last_notice_at => nil}, {:first_notice_at => nil}]).each do |problem| | |
4 | - first_notice = problem.notices.order_by([:created_at, :asc]).first | |
5 | - | |
6 | - # Destroy problems with no notices | |
7 | - if first_notice.nil? | |
8 | - problem.destroy | |
9 | - next | |
10 | - end | |
11 | - | |
12 | - last_notice = problem.notices.order_by([:created_at, :asc]).last | |
13 | - | |
14 | - problem.update_attributes!({ | |
15 | - :first_notice_at => first_notice.created_at, | |
16 | - :last_notice_at => last_notice.created_at | |
17 | - }) | |
18 | - end | |
19 | - end | |
20 | - | |
21 | - def self.down | |
22 | - end | |
23 | -end |
db/migrate/20121003223358_extract_backtraces.rb
... | ... | @@ -1,16 +0,0 @@ |
1 | -class ExtractBacktraces < Mongoid::Migration | |
2 | - def self.up | |
3 | - say "It could take long time (hours if you have many Notices)" | |
4 | - Notice.unscoped.where(backtrace_id: nil).each do |notice| | |
5 | - next if notice.backtrace.present? || notice['backtrace'].nil? | |
6 | - backtrace = Backtrace.find_or_create(:raw => notice['backtrace'] || []) | |
7 | - notice.unset(:backtrace) | |
8 | - notice.backtrace = backtrace | |
9 | - notice.save! | |
10 | - end | |
11 | - say "run `db.repairDatabase()` (in mongodb console) to recover deleted space" | |
12 | - end | |
13 | - | |
14 | - def self.down | |
15 | - end | |
16 | -end |
db/migrate/20121005142110_regenerate_err_fingerprints.rb
... | ... | @@ -1,15 +0,0 @@ |
1 | -class RegenerateErrFingerprints < Mongoid::Migration | |
2 | - def self.up | |
3 | - Err.all.each do |err| | |
4 | - if err.notices.any? && err.problem | |
5 | - err.update_attribute( | |
6 | - :fingerprint, | |
7 | - Fingerprint::Sha1.generate(err.notices.first, err.app.api_key) | |
8 | - ) | |
9 | - end | |
10 | - end | |
11 | - end | |
12 | - | |
13 | - def self.down | |
14 | - end | |
15 | -end |
db/migrate/20130208135718_allow_custom_xmpp_on_gtalk.rb.rb
... | ... | @@ -1,17 +0,0 @@ |
1 | -class AllowCustomXmppOnGtalk < Mongoid::Migration | |
2 | - def self.up | |
3 | - App.all.each do |app| | |
4 | - if app.notification_service and app.notification_service._type.include?("Gtalk") | |
5 | - user_id = app.notification_service.room_id | |
6 | - app.notification_service.update_attributes(:service => 'talk.google.com', | |
7 | - :service_url => "http://www.google.com/talk/", | |
8 | - :user_id => user_id, | |
9 | - :room_id => nil) | |
10 | - | |
11 | - end | |
12 | - end | |
13 | - end | |
14 | - | |
15 | - def self.down | |
16 | - end | |
17 | -end |
db/migrate/20130212112719_add_interval_field_for_notifications.rb
db/migrate/20131011155638_extract_issue_tracker.rb
... | ... | @@ -1,46 +0,0 @@ |
1 | -class ExtractIssueTracker < Mongoid::Migration | |
2 | - | |
3 | - TRACKER_MAPPING = { | |
4 | - 'ErrbitTracPlugin::IssueTracker' => 'trac', | |
5 | - 'IssueTrackers::BitbucketIssuesTracker' => 'bitbucket', | |
6 | - 'IssueTrackers::FogbugzTracker' => 'fogbugz', | |
7 | - 'IssueTrackers::GithubIssuesTracker' => 'github', | |
8 | - 'IssueTrackers::GitlabTracker' => 'gitlab', | |
9 | - 'IssueTrackers::JiraTracker' => 'jira', | |
10 | - 'IssueTrackers::LighthouseTracker' => 'lighthouse', | |
11 | - 'IssueTrackers::PivotalLabsTracker' => 'pivotal', | |
12 | - 'IssueTrackers::RedmineTracker' => 'redmine', | |
13 | - 'IssueTrackers::UnfuddleTracker' => 'unfuddle' | |
14 | - } | |
15 | - | |
16 | - def self.up | |
17 | - App.all.each do |app| | |
18 | - next unless app.attributes['issue_tracker'].present? | |
19 | - next unless app.attributes['issue_tracker']['_type'].present? | |
20 | - | |
21 | - options = app['issue_tracker'].dup | |
22 | - options.delete('_type') | |
23 | - options.delete('_id') | |
24 | - | |
25 | - _type = app.attributes['issue_tracker']['_type'] | |
26 | - updated_at = options.delete('updated_at') | |
27 | - created_at = options.delete('created_at') | |
28 | - | |
29 | - if TRACKER_MAPPING.include?(_type) | |
30 | - tracker = { | |
31 | - 'type_tracker' => TRACKER_MAPPING[_type], | |
32 | - 'options' => options, | |
33 | - 'updated_at' => updated_at, | |
34 | - 'created_at' => created_at | |
35 | - } | |
36 | - | |
37 | - App.collection.where({ _id: app.id }).update({ | |
38 | - "$set" => { :issue_tracker => tracker } | |
39 | - }) | |
40 | - end | |
41 | - end | |
42 | - end | |
43 | - | |
44 | - def self.down | |
45 | - end | |
46 | -end |