Skip to content

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

Revert "Revert "[#48717] Add forgotten GoodJob migrations.""

Oliver Günthercd05d7de53b0
diff --git a/db/migrate/20240306154734_create_good_job_labels.rb b/db/migrate/20240306154734_create_good_job_labels.rb
new file mode 100644
index 00000000000..48e9770eedb
--- /dev/null
+++ b/db/migrate/20240306154734_create_good_job_labels.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+#-- 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 CreateGoodJobLabels < ActiveRecord::Migration[7.1]
+ def change
+ reversible do |dir|
+ dir.up do
+ # Ensure this incremental update migration is idempotent
+ # with monolithic install migration.
+ return if connection.column_exists?(:good_jobs, :labels)
+ end
+ end
+
+ add_column :good_jobs, :labels, :text, array: true
+ end
+end
diff --git a/db/migrate/20240306154735_create_good_job_labels_index.rb b/db/migrate/20240306154735_create_good_job_labels_index.rb
new file mode 100644
index 00000000000..cbfc6879356
--- /dev/null
+++ b/db/migrate/20240306154735_create_good_job_labels_index.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+#-- 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 CreateGoodJobLabelsIndex < ActiveRecord::Migration[7.1]
+ disable_ddl_transaction!
+
+ def change
+ reversible do |dir|
+ dir.up do
+ unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels)
+ add_index :good_jobs, :labels, using: :gin, where: "(labels IS NOT NULL)",
+ name: :index_good_jobs_on_labels, algorithm: :concurrently
+ end
+ end
+
+ dir.down do
+ if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_labels)
+ remove_index :good_jobs, name: :index_good_jobs_on_labels
+ end
+ end
+ end
+ end
+end
diff --git a/db/migrate/20240306154736_remove_good_job_active_id_index.rb b/db/migrate/20240306154736_remove_good_job_active_id_index.rb
new file mode 100644
index 00000000000..f54d20488a1
--- /dev/null
+++ b/db/migrate/20240306154736_remove_good_job_active_id_index.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+#-- 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 RemoveGoodJobActiveIdIndex < ActiveRecord::Migration[7.1]
+ disable_ddl_transaction!
+
+ def change
+ reversible do |dir|
+ dir.up do
+ if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)
+ remove_index :good_jobs, name: :index_good_jobs_on_active_job_id
+ end
+ end
+
+ dir.down do
+ unless connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)
+ add_index :good_jobs, :active_job_id, name: :index_good_jobs_on_active_job_id
+ end
+ end
+ end
+ end
+end
diff --git a/db/migrate/20240306154737_create_index_good_job_jobs_for_candidate_lookup.rb b/db/migrate/20240306154737_create_index_good_job_jobs_for_candidate_lookup.rb
new file mode 100644
index 00000000000..318fc758d4e
--- /dev/null
+++ b/db/migrate/20240306154737_create_index_good_job_jobs_for_candidate_lookup.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+#-- 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 CreateIndexGoodJobJobsForCandidateLookup < ActiveRecord::Migration[7.1]
+ disable_ddl_transaction!
+
+ def change
+ reversible do |dir|
+ dir.up do
+ # Ensure this incremental update migration is idempotent
+ # with monolithic install migration.
+ return if connection.index_name_exists?(:good_jobs, :index_good_job_jobs_for_candidate_lookup)
+ end
+ end
+
+ add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc },
+ where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup,
+ algorithm: :concurrently
+ end
+end