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
This commit is contained in:
parent
a773f70f7b
commit
55d28efa1f
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Setting NOT NULL constraint to users.private_profile column
|
||||
merge_request: 14838
|
||||
author:
|
||||
type: other
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -1176,7 +1176,7 @@ describe User do
|
|||
expect(user.can_create_group).to eq(Gitlab.config.gitlab.default_can_create_group)
|
||||
expect(user.theme_id).to eq(Gitlab.config.gitlab.default_theme)
|
||||
expect(user.external).to be_falsey
|
||||
expect(user.private_profile).to eq false
|
||||
expect(user.private_profile).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue