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

[#47045] Prepare the database to have project folder data.

Andreas Pfohlc9b9a3c8fb6a
diff --git a/modules/storages/app/models/storages/project_storage.rb b/modules/storages/app/models/storages/project_storage.rb
index 0840c96b224..53e054b506d 100644
--- a/modules/storages/app/models/storages/project_storage.rb
+++ b/modules/storages/app/models/storages/project_storage.rb
@@ -42,4 +42,9 @@ class Storages::ProjectStorage < ApplicationRecord
# There should be only one ProjectStorage per project and storage.
validates :project, uniqueness: { scope: :storage }
+
+ enum project_folder_mode: {
+ inactive: 'inactive',
+ manual: 'manual'
+ }, _prefix: 'project_folder'
end
diff --git a/modules/storages/db/migrate/20230321194150_add_project_folder_to_projects_storages.rb b/modules/storages/db/migrate/20230321194150_add_project_folder_to_projects_storages.rb
new file mode 100644
index 00000000000..1e6ca7ba403
--- /dev/null
+++ b/modules/storages/db/migrate/20230321194150_add_project_folder_to_projects_storages.rb
@@ -0,0 +1,47 @@
+#-- 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 AddProjectFolderToProjectsStorages < ActiveRecord::Migration[7.0]
+ def up
+ create_enum :project_folder_modes, %w[inactive manual]
+
+ change_table :projects_storages do |table|
+ table.string :project_folder_id
+ table.enum :project_folder_mode, enum_type: :project_folder_modes, default: :inactive, null: false
+ end
+ end
+
+ def down
+ remove_column :projects_storages, :project_folder_id
+ remove_column :projects_storages, :project_folder_mode
+
+ execute <<-SQL.squish
+ drop type project_folder_modes;
+ SQL
+ end
+end