diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2019-05-31 09:59:36 +0000 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2019-05-31 09:59:36 +0000 |
commit | 724b5afbd99ab31242eed386d9169a1f1b5a7610 (patch) | |
tree | 46a00a2e87d440a106c11006ce2099c242af8293 /db | |
parent | bc32249b30f294db242928e9f76a353d2e7e5b5e (diff) | |
download | gitlab-ce-724b5afbd99ab31242eed386d9169a1f1b5a7610.tar.gz |
Remove nils from project_statistics.packages_size
Now it defaults to 0
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20190516155724_change_packages_size_defaults_in_project_statistics.rb | 24 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/db/migrate/20190516155724_change_packages_size_defaults_in_project_statistics.rb b/db/migrate/20190516155724_change_packages_size_defaults_in_project_statistics.rb new file mode 100644 index 00000000000..eba154df496 --- /dev/null +++ b/db/migrate/20190516155724_change_packages_size_defaults_in_project_statistics.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class ChangePackagesSizeDefaultsInProjectStatistics < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + change_column_default :project_statistics, :packages_size, 0 + + update_column_in_batches(:project_statistics, :packages_size, 0) do |table, query| + query.where(table[:packages_size].eq(nil)) + end + + change_column_null :project_statistics, :packages_size, false + end + + def down + change_column_null :project_statistics, :packages_size, true + change_column_default :project_statistics, :packages_size, nil + end +end diff --git a/db/schema.rb b/db/schema.rb index 89140048ad3..1fdfb73eb59 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1744,7 +1744,7 @@ ActiveRecord::Schema.define(version: 20190527194900) do t.bigint "repository_size", default: 0, null: false t.bigint "lfs_objects_size", default: 0, null: false t.bigint "build_artifacts_size", default: 0, null: false - t.bigint "packages_size" + t.bigint "packages_size", default: 0, null: false t.bigint "wiki_size" t.index ["namespace_id"], name: "index_project_statistics_on_namespace_id", using: :btree t.index ["project_id"], name: "index_project_statistics_on_project_id", unique: true, using: :btree |