From 0294e4bc4ae3a6a5d22f0f9a23f8f6fb5c469d64 Mon Sep 17 00:00:00 2001 From: Pavel Balashou Date: Thu, 29 Feb 2024 14:54:01 +0100 Subject: [PATCH] Rename delayed_job_statuses to job_statuses. --- ...40229133250_rename_delayed_job_statuses.rb | 33 +++++++++++++++++++ .../app/models/job_status/status.rb | 30 ++++++++++++++++- .../job_status/application_job_with_status.rb | 2 +- 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20240229133250_rename_delayed_job_statuses.rb diff --git a/db/migrate/20240229133250_rename_delayed_job_statuses.rb b/db/migrate/20240229133250_rename_delayed_job_statuses.rb new file mode 100644 index 000000000000..43ffd4dd4577 --- /dev/null +++ b/db/migrate/20240229133250_rename_delayed_job_statuses.rb @@ -0,0 +1,33 @@ +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2024 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +class RenameDelayedJobStatuses < ActiveRecord::Migration[7.1] + def change + rename_table :delayed_job_statuses, :job_statuses + end +end diff --git a/modules/job_status/app/models/job_status/status.rb b/modules/job_status/app/models/job_status/status.rb index 6f4b3bc6a8e8..928b40d91fa3 100644 --- a/modules/job_status/app/models/job_status/status.rb +++ b/modules/job_status/app/models/job_status/status.rb @@ -1,6 +1,34 @@ +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2024 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + module JobStatus class Status < ApplicationRecord - self.table_name = 'delayed_job_statuses' + self.table_name = 'job_statuses' belongs_to :user belongs_to :reference, polymorphic: true diff --git a/modules/job_status/app/workers/job_status/application_job_with_status.rb b/modules/job_status/app/workers/job_status/application_job_with_status.rb index 9aa2c8291b81..e0c6e128fce0 100644 --- a/modules/job_status/app/workers/job_status/application_job_with_status.rb +++ b/modules/job_status/app/workers/job_status/application_job_with_status.rb @@ -74,7 +74,7 @@ def upsert_status(status:, **args) resource.attributes = build_status_attributes(args.merge(status:)) end - # There is a possible race condition because of unique delayed_job_statuses.job_id + # There is a possible race condition because of unique job_statuses.job_id # Can't use upsert easily, because before updating we need to know user_id # to set proper locale. Probably, it is possible to get it from # a job's payload, then it would be possible to correctly prepare attributes before using upsert.