From a063f244362f7b6a3e3ae3695ebe78306244f8ab Mon Sep 17 00:00:00 2001
From: Vladimir Shushlin <vshushlin@gitlab.com>
Date: Wed, 25 Sep 2019 09:43:34 +0000
Subject: [PATCH] Add columns pages/artifacts size limits

* projects
* namespaces
---
 .../unreleased/pages-per-project-size-limit-db.yml       | 5 +++++
 db/migrate/20190911115056_add_projects_max_pages_size.rb | 9 +++++++++
 .../20190911115109_add_namespaces_max_pages_size.rb      | 9 +++++++++
 .../20190911115207_add_projects_max_artifacts_size.rb    | 9 +++++++++
 .../20190911115222_add_namespaces_max_artifacts_size.rb  | 9 +++++++++
 db/schema.rb                                             | 4 ++++
 lib/gitlab/import_export/import_export.yml               | 2 ++
 7 files changed, 47 insertions(+)
 create mode 100644 changelogs/unreleased/pages-per-project-size-limit-db.yml
 create mode 100644 db/migrate/20190911115056_add_projects_max_pages_size.rb
 create mode 100644 db/migrate/20190911115109_add_namespaces_max_pages_size.rb
 create mode 100644 db/migrate/20190911115207_add_projects_max_artifacts_size.rb
 create mode 100644 db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb

diff --git a/changelogs/unreleased/pages-per-project-size-limit-db.yml b/changelogs/unreleased/pages-per-project-size-limit-db.yml
new file mode 100644
index 000000000000..97a24b356e64
--- /dev/null
+++ b/changelogs/unreleased/pages-per-project-size-limit-db.yml
@@ -0,0 +1,5 @@
+---
+title: Add columns for per project/group max pages/artifacts sizes
+merge_request: 17231
+author:
+type: added
diff --git a/db/migrate/20190911115056_add_projects_max_pages_size.rb b/db/migrate/20190911115056_add_projects_max_pages_size.rb
new file mode 100644
index 000000000000..175c66953ed8
--- /dev/null
+++ b/db/migrate/20190911115056_add_projects_max_pages_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectsMaxPagesSize < ActiveRecord::Migration[5.2]
+  DOWNTIME = false
+
+  def change
+    add_column :projects, :max_pages_size, :integer
+  end
+end
diff --git a/db/migrate/20190911115109_add_namespaces_max_pages_size.rb b/db/migrate/20190911115109_add_namespaces_max_pages_size.rb
new file mode 100644
index 000000000000..c14dfa74a5a1
--- /dev/null
+++ b/db/migrate/20190911115109_add_namespaces_max_pages_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddNamespacesMaxPagesSize < ActiveRecord::Migration[5.2]
+  DOWNTIME = false
+
+  def change
+    add_column :namespaces, :max_pages_size, :integer
+  end
+end
diff --git a/db/migrate/20190911115207_add_projects_max_artifacts_size.rb b/db/migrate/20190911115207_add_projects_max_artifacts_size.rb
new file mode 100644
index 000000000000..41cab7e5282f
--- /dev/null
+++ b/db/migrate/20190911115207_add_projects_max_artifacts_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddProjectsMaxArtifactsSize < ActiveRecord::Migration[5.2]
+  DOWNTIME = false
+
+  def change
+    add_column :projects, :max_artifacts_size, :integer
+  end
+end
diff --git a/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb b/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb
new file mode 100644
index 000000000000..60c594c47a6c
--- /dev/null
+++ b/db/migrate/20190911115222_add_namespaces_max_artifacts_size.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class AddNamespacesMaxArtifactsSize < ActiveRecord::Migration[5.2]
+  DOWNTIME = false
+
+  def change
+    add_column :namespaces, :max_artifacts_size, :integer
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7703628d4337..a4d244e556f4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2317,6 +2317,8 @@
     t.integer "last_ci_minutes_usage_notification_level"
     t.integer "subgroup_creation_level", default: 1
     t.boolean "emails_disabled"
+    t.integer "max_pages_size"
+    t.integer "max_artifacts_size"
     t.index ["created_at"], name: "index_namespaces_on_created_at"
     t.index ["custom_project_templates_group_id", "type"], name: "index_namespaces_on_custom_project_templates_group_id_and_type", where: "(custom_project_templates_group_id IS NOT NULL)"
     t.index ["file_template_project_id"], name: "index_namespaces_on_file_template_project_id"
@@ -2909,6 +2911,8 @@
     t.boolean "merge_requests_disable_committers_approval"
     t.boolean "require_password_to_approve"
     t.boolean "emails_disabled"
+    t.integer "max_pages_size"
+    t.integer "max_artifacts_size"
     t.index ["archived", "pending_delete", "merge_requests_require_code_owner_approval"], name: "projects_requiring_code_owner_approval", where: "((pending_delete = false) AND (archived = false) AND (merge_requests_require_code_owner_approval = true))"
     t.index ["created_at"], name: "index_projects_on_created_at"
     t.index ["creator_id"], name: "index_projects_on_creator_id"
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index 511b702553e6..994aa95dc5e9 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -143,6 +143,8 @@ excluded_attributes:
     - :mirror_last_update_at
     - :mirror_last_successful_update_at
     - :emails_disabled
+    - :max_pages_size
+    - :max_artifacts_size
   namespaces:
     - :runners_token
     - :runners_token_encrypted
-- 
GitLab