diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-17 14:31:24 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-17 14:49:00 +0200 |
commit | 7d98c8842d6bc9b14fb410f028db7ab651961b42 (patch) | |
tree | 9cbf2db66275adff0f527d0219393db4c8b7248f /app | |
parent | dfebcb89e64d2e4b3ebd2d69b6ae386b6fcc5be0 (diff) | |
download | gitlab-ce-7d98c8842d6bc9b14fb410f028db7ab651961b42.tar.gz |
Move import data out of project so it doesn't take ages to load.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 8 | ||||
-rw-r--r-- | app/models/project_import_data.rb | 19 |
2 files changed, 22 insertions, 5 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index c4f50e02ddd..64ee2c2212b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -27,7 +27,6 @@ # import_type :string(255) # import_source :string(255) # avatar :string(255) -# import_data :text # require 'carrierwave/orm/activerecord' @@ -51,8 +50,6 @@ class Project < ActiveRecord::Base default_value_for :wall_enabled, false default_value_for :snippets_enabled, gitlab_config_features.snippets - serialize :import_data, JSON - # set last_activity_at to the same as created_at after_create :set_last_activity_at def set_last_activity_at @@ -117,6 +114,8 @@ class Project < ActiveRecord::Base has_many :users_star_projects, dependent: :destroy has_many :starrers, through: :users_star_projects, source: :user + has_one :import_data, dependent: :destroy, class_name: "ProjectImportData" + delegate :name, to: :owner, allow_nil: true, prefix: true delegate :members, to: :team, prefix: true @@ -267,8 +266,7 @@ class Project < ActiveRecord::Base end def clear_import_data - self.import_data = nil - self.save + self.import_data.destroy if self.import_data end def import? diff --git a/app/models/project_import_data.rb b/app/models/project_import_data.rb new file mode 100644 index 00000000000..6a8a8a56eb5 --- /dev/null +++ b/app/models/project_import_data.rb @@ -0,0 +1,19 @@ +# == Schema Information +# +# Table name: project_import_datas +# +# id :integer not null, primary key +# project_id :integer +# data :text +# + +require 'carrierwave/orm/activerecord' +require 'file_size_validator' + +class ProjectImportData < ActiveRecord::Base + belongs_to :project + + serialize :data, JSON + + validates :project, presence: true +end |