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
also fix the time entries with root activities
ulferts7494773bba63
diff --git a/lib/tasks/time_entry_activities.rake b/lib/tasks/time_entry_activities.rakeindex 27ea026b5d1..c97aedc48e7 100644--- a/lib/tasks/time_entry_activities.rake+++ b/lib/tasks/time_entry_activities.rake@@ -43,15 +43,36 @@ namespace 'openproject' donextend+ check_statement = <<~SQL+ SELECT+ te_source.id,+ enumerations.parent_id+ FROM+ time_entries te_source+ INNER JOIN+ enumerations+ ON te_source.activity_id = enumerations.id AND enumerations.parent_id IS NOT NULL AND enumerations.type = 'TimeEntryActivity'+ SQL+select_statement = <<~SQL- SELECT te_source.id, enumerations.parent_id FROM time_entries te_source INNER JOIN enumerations ON te_source.activity_id = enumerations.id AND enumerations.parent_id IS NOT NULL AND enumerations.type = 'TimeEntryActivity'+ SELECT+ te_source.id,+ COALESCE(enumerations.parent_id, enumerations.id) activity_id+ FROM time_entries te_source+ LEFT OUTER JOIN+ enumerations+ ON te_source.activity_id = enumerations.id+ WHERE enumerations.type = 'TimeEntryActivity'SQLentries = beginconnection = ActiveRecord::Base.establish_connection(ENV['BACKUP_DATABASE_URL']).connection- connection.select_all(select_statement)++ if connection.select_all(check_statement).any?+ connection.select_all(select_statement)+ endrescue PG::ConnectionBad, ActiveRecord::NoDatabaseError, LoadError => eputs <<~MSG@@ -64,7 +85,7 @@ namespace 'openproject' doconnection&.closeend- unless entries.any?+ if entries.nil? || entries.empty?puts <<~MSG@@ -75,7 +96,7 @@ namespace 'openproject' donextend- entries_string = entries.map { |entry| "(#{entry['id']}, #{entry['parent_id']})" }.join(', ')+ entries_string = entries.map { |entry| "(#{entry['id']}, #{entry['activity_id']})" }.join(', ')update_statement = <<~SQLUPDATE time_entries