OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Remove invalid time entry references before adding logged_by
Oliver Günther7d35386eced1
diff --git a/db/migrate/20220707192304_backfill_time_entries_with_logged_by_id.rb b/db/migrate/20220707192304_backfill_time_entries_with_logged_by_id.rbindex 60acb376cf9..e2926daed60 100644--- a/db/migrate/20220707192304_backfill_time_entries_with_logged_by_id.rb+++ b/db/migrate/20220707192304_backfill_time_entries_with_logged_by_id.rb@@ -1,5 +1,13 @@class BackfillTimeEntriesWithLoggedById < ActiveRecord::Migration[7.0]- def change+ def up+ TimeEntry+ .where.not(user_id: User.select(:id))+ .update_all(user_id: DeletedUser.first.id)+TimeEntry.all.update_all('logged_by_id = user_id')end++ def down+ # Nothing to do+ endenddiff --git a/db/migrate/20220815072420_add_logged_by_to_time_entries_journals.rb b/db/migrate/20220815072420_add_logged_by_to_time_entries_journals.rbindex cbd152e4772..f73aa1f8aa2 100644--- a/db/migrate/20220815072420_add_logged_by_to_time_entries_journals.rb+++ b/db/migrate/20220815072420_add_logged_by_to_time_entries_journals.rb@@ -4,6 +4,10 @@ class AddLoggedByToTimeEntriesJournals < ActiveRecord::Migration[7.0]reversible do |change|change.up do+ Journal::TimeEntryJournal+ .where.not(user_id: User.select(:id))+ .update_all(user_id: DeletedUser.first.id)+execute <<~SQL.squishUPDATE time_entry_journalsSET logged_by_id = user_id