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
[#47048] Prepare the database migration
Andreas Pfohla798560c9ba9
diff --git a/modules/storages/app/models/storages/last_project_folder.rb b/modules/storages/app/models/storages/last_project_folder.rbnew file mode 100644index 00000000000..54877911888--- /dev/null+++ b/modules/storages/app/models/storages/last_project_folder.rb@@ -0,0 +1,31 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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 Storages::LastProjectFolder < ApplicationRecord+ belongs_to :projects_storage, class_name: 'Storages::ProjectStorage'+enddiff --git a/modules/storages/app/models/storages/project_storage.rb b/modules/storages/app/models/storages/project_storage.rbindex 9558009fb1d..a0d2e656fde 100644--- a/modules/storages/app/models/storages/project_storage.rb+++ b/modules/storages/app/models/storages/project_storage.rb@@ -40,6 +40,11 @@ class Storages::ProjectStorage < ApplicationRecordbelongs_to :storage, touch: true, class_name: 'Storages::Storage'belongs_to :creator, class_name: 'User'+ has_many :last_project_folders,+ class_name: 'Storages::LastProjectFolder',+ dependent: :destroy,+ foreign_key: :projects_storage_id+# There should be only one ProjectStorage per project and storage.validates :project, uniqueness: { scope: :storage }diff --git a/modules/storages/db/migrate/20230601082746_create_last_project_folders.rb b/modules/storages/db/migrate/20230601082746_create_last_project_folders.rbnew file mode 100644index 00000000000..7ac7310f0ee--- /dev/null+++ b/modules/storages/db/migrate/20230601082746_create_last_project_folders.rb@@ -0,0 +1,40 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 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 CreateLastProjectFolders < ActiveRecord::Migration[7.0]+ def change+ create_table :last_project_folders,+ comment: 'This table contains the last used project folder IDs for a project storage per mode.' do |t|+ t.references :projects_storage, null: false, foreign_key: { on_delete: :cascade }+ t.string :origin_folder_id+ t.enum :mode, enum_type: :project_folder_modes, default: :inactive, null: false+ t.index %i[projects_storage_id mode], unique: true+ t.timestamps+ end+ end+end