Fix migration and model for ProjectStorage

pull/10133/head
Wieland Lindenthal 3 years ago
parent 48e9b12a15
commit cf99edc7f0
No known key found for this signature in database
GPG Key ID: 7ACCABE64832A0C6
  1. 4
      db/migrate/20220113144759_create_file_links.rb
  2. 11
      db/migrate/20220121090847_create_projects_storages.rb
  3. 2
      modules/storages/app/controllers/storages/admin/projects_storages_controller.rb
  4. 4
      modules/storages/app/models/storages/project_storage.rb

@ -20,9 +20,9 @@ class CreateFileLinks < ActiveRecord::Migration[6.1]
t.timestamps
# i.e. show all file links per WP.
t.index [:container_id, :container_type]
t.index %i[container_id container_type]
# i.e. show all work packages per file.
t.index [:origin_id, :storage_id]
t.index %i[origin_id storage_id]
end
end
end

@ -1,14 +1,15 @@
class CreateProjectsStorages < ActiveRecord::Migration[6.1]
def change
create_table :projects_storages do |t|
t.bigint :project_id, null: false, foreign_key: true
t.bigint :storage_id, null: false, foreign_key: true
t.bigint :creator_id, null: false, foreign_key: true
t.references :project, null: false, foreign_key: true, on_delete: :cascade
t.references :storage, null: false, foreign_key: true, on_delete: :cascade
t.references :creator,
null: false,
index: true,
foreign_key: { to_table: :users }
t.timestamps
t.index :project_id
t.index :storage_id
t.index %i[project_id storage_id], unique: true
end
end

@ -2,7 +2,7 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
# Copyright (C) 2012-2022 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.

@ -2,7 +2,7 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
# Copyright (C) 2012-2022 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.
@ -30,7 +30,7 @@
class Storages::ProjectStorage < ApplicationRecord
self.table_name = 'projects_storages'
belongs_to :project, class_name: 'Project'
belongs_to :project
belongs_to :storage, class_name: 'Storages::Storage'
belongs_to :creator, class_name: 'User'

Loading…
Cancel
Save