diff options
author | Adam Hegyi <ahegyi@gitlab.com> | 2019-08-28 13:38:50 +0000 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2019-08-28 13:38:50 +0000 |
commit | 55d28efa1f1fb0d2ce074ac3ebecf6d4e67aaa90 (patch) | |
tree | 84ca61d57b7ccbfbed42d3fa8af847209bc7b169 /db | |
parent | a773f70f7b9c61b5e1445c1e9b3f44ebacf6c230 (diff) | |
download | gitlab-ce-55d28efa1f1fb0d2ce074ac3ebecf6d4e67aaa90.tar.gz |
Adding NOT NULL constraint to private_profile
This change sets NOT NULL constraint to users.private profile.
closes https://gitlab.com/gitlab-org/gitlab-ce/issues/57538
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20190725080128_set_not_null_on_users_private_profile.rb | 26 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/db/post_migrate/20190725080128_set_not_null_on_users_private_profile.rb b/db/post_migrate/20190725080128_set_not_null_on_users_private_profile.rb new file mode 100644 index 00000000000..db42e949d3f --- /dev/null +++ b/db/post_migrate/20190725080128_set_not_null_on_users_private_profile.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +class SetNotNullOnUsersPrivateProfile < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + Gitlab::BackgroundMigration.steal('MigrateNullPrivateProfileToFalse') + + # rubocop:disable Migration/UpdateLargeTable + # rubocop:disable Migration/UpdateColumnInBatches + # Data has been migrated previously, count should be close to 0 + update_column_in_batches(:users, :private_profile, false) do |table, query| + query.where(table[:private_profile].eq(nil)) + end + + change_column_null :users, :private_profile, false + end + + def down + change_column_null :users, :private_profile, true + end +end diff --git a/db/schema.rb b/db/schema.rb index f30dad3d030..6c6c2796b9a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -3499,7 +3499,7 @@ ActiveRecord::Schema.define(version: 2019_08_20_163320) do t.integer "theme_id", limit: 2 t.integer "accepted_term_id" t.string "feed_token" - t.boolean "private_profile", default: false + t.boolean "private_profile", default: false, null: false t.boolean "include_private_contributions" t.string "commit_email" t.boolean "auditor", default: false, null: false |