Commit 76454805 authored by charlie ablett's avatar charlie ablett Committed by Luke Duncalfe
parent 758c2fd6
# frozen_string_literal: true
class ChangeNamespaceTypeDefaultToUser < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
def up
with_lock_retries do
change_column_default :namespaces, :type, 'User'
end
end
def down
with_lock_retries do
change_column_default :namespaces, :type, nil
end
end
end
d71889bba2150265e9482be0b5ee89f43168d4a35b47469a36873d65f00df878
\ No newline at end of file
......@@ -16353,7 +16353,7 @@ CREATE TABLE namespaces (
owner_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone,
type character varying,
type character varying DEFAULT 'User'::character varying,
description character varying DEFAULT ''::character varying NOT NULL,
avatar character varying,
membership_lock boolean DEFAULT false,
......@@ -15,7 +15,7 @@ RSpec.describe ::Gitlab::BackgroundMigration::PopulateResolvedOnDefaultBranchCol
let(:scanners) { table(:vulnerability_scanners) }
let(:vulnerability_identifiers) { table(:vulnerability_identifiers) }
let(:namespace) { namespaces.create!(name: "foo", path: "bar") }
let(:namespace) { namespaces.create!(name: "foo", path: "bar", type: "Group") }
describe '#perform' do
let!(:project_1) { projects.create!(namespace_id: namespace.id) }
......
......@@ -4,8 +4,10 @@ require 'spec_helper'
RSpec.describe Ci::Minutes::RefreshCachedDataService do
include AfterNextHelpers
let_it_be(:project_1) { create(:project) }
let_it_be(:root_namespace) { project_1.root_namespace }
let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:project_1) { create(:project, group: group) }
let_it_be(:root_namespace) { group }
let_it_be(:build_1) { create(:ci_build, :pending, project: project_1) }
let_it_be(:build_2) { create(:ci_build, :pending) }
let_it_be(:pending_build_1) { create(:ci_pending_build, build: build_1, project: build_1.project, minutes_exceeded: true) }
......
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe ChangeNamespaceTypeDefaultToUser do
let(:namespaces) { table(:namespaces) }
it 'defaults type to User' do
some_namespace1 = namespaces.create!(name: 'magic namespace1', path: 'magicnamespace1', type: nil)
expect(some_namespace1.reload.type).to be_nil
migrate!
some_namespace2 = namespaces.create!(name: 'magic namespace2', path: 'magicnamespace2', type: nil)
expect(some_namespace1.reload.type).to be_nil
expect(some_namespace2.reload.type).to eq 'User'
end
end
......@@ -9,6 +9,7 @@ RSpec.describe CaseSensitivity do
Class.new(ActiveRecord::Base) do
include CaseSensitivity
self.table_name = 'namespaces'
self.inheritance_column = :_type_disabled
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment