Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4dae8709
Commit
4dae8709
authored
Jan 13, 2022
by
Brett Walker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add member_namespace_id to members table
in support of upcoming work on members table Changelog: changed
parent
829106c0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
1 deletion
+46
-1
app/models/member.rb
app/models/member.rb
+2
-0
app/models/namespace.rb
app/models/namespace.rb
+1
-0
db/migrate/20220112232037_add_member_namespace_reference.rb
db/migrate/20220112232037_add_member_namespace_reference.rb
+13
-0
db/migrate/20220112232605_add_member_namespace_index.rb
db/migrate/20220112232605_add_member_namespace_index.rb
+19
-0
db/schema_migrations/20220112232037
db/schema_migrations/20220112232037
+1
-0
db/schema_migrations/20220112232605
db/schema_migrations/20220112232605
+1
-0
db/structure.sql
db/structure.sql
+7
-1
spec/models/member_spec.rb
spec/models/member_spec.rb
+1
-0
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+1
-0
No files found.
app/models/member.rb
View file @
4dae8709
...
@@ -27,6 +27,8 @@ class Member < ApplicationRecord
...
@@ -27,6 +27,8 @@ class Member < ApplicationRecord
belongs_to
:created_by
,
class_name:
"User"
belongs_to
:created_by
,
class_name:
"User"
belongs_to
:user
belongs_to
:user
belongs_to
:source
,
polymorphic:
true
# rubocop:disable Cop/PolymorphicAssociations
belongs_to
:source
,
polymorphic:
true
# rubocop:disable Cop/PolymorphicAssociations
belongs_to
:member_namespace
,
inverse_of: :namespace_members
,
foreign_key:
'member_namespace_id'
,
class_name:
'Namespace'
belongs_to
:namespace
,
inverse_of: :namespace_route
has_one
:member_task
has_one
:member_task
delegate
:name
,
:username
,
:email
,
:last_activity_on
,
to: :user
,
prefix:
true
delegate
:name
,
:username
,
:email
,
:last_activity_on
,
to: :user
,
prefix:
true
...
...
app/models/namespace.rb
View file @
4dae8709
...
@@ -44,6 +44,7 @@ class Namespace < ApplicationRecord
...
@@ -44,6 +44,7 @@ class Namespace < ApplicationRecord
has_many
:project_statistics
has_many
:project_statistics
has_one
:namespace_settings
,
inverse_of: :namespace
,
class_name:
'NamespaceSetting'
,
autosave:
true
has_one
:namespace_settings
,
inverse_of: :namespace
,
class_name:
'NamespaceSetting'
,
autosave:
true
has_one
:namespace_route
,
foreign_key: :namespace_id
,
autosave:
false
,
inverse_of: :namespace
,
class_name:
'Route'
has_one
:namespace_route
,
foreign_key: :namespace_id
,
autosave:
false
,
inverse_of: :namespace
,
class_name:
'Route'
has_many
:namespace_members
,
foreign_key: :member_namespace_id
,
inverse_of: :member_namespace
,
class_name:
'Member'
has_many
:runner_namespaces
,
inverse_of: :namespace
,
class_name:
'Ci::RunnerNamespace'
has_many
:runner_namespaces
,
inverse_of: :namespace
,
class_name:
'Ci::RunnerNamespace'
has_many
:runners
,
through: :runner_namespaces
,
source: :runner
,
class_name:
'Ci::Runner'
has_many
:runners
,
through: :runner_namespaces
,
source: :runner
,
class_name:
'Ci::Runner'
...
...
db/migrate/20220112232037_add_member_namespace_reference.rb
0 → 100644
View file @
4dae8709
# frozen_string_literal: true
class
AddMemberNamespaceReference
<
Gitlab
::
Database
::
Migration
[
1.0
]
enable_lock_retries!
def
up
add_column
:members
,
:member_namespace_id
,
:bigint
unless
column_exists?
(
:members
,
:member_namespace_id
)
end
def
down
remove_column
:members
,
:member_namespace_id
if
column_exists?
(
:members
,
:member_namespace_id
)
end
end
db/migrate/20220112232605_add_member_namespace_index.rb
0 → 100644
View file @
4dae8709
# frozen_string_literal: true
class
AddMemberNamespaceIndex
<
Gitlab
::
Database
::
Migration
[
1.0
]
disable_ddl_transaction!
INDEX_NAME
=
'index_members_on_member_namespace_id'
def
up
add_concurrent_index
:members
,
:member_namespace_id
,
unique:
false
,
name:
INDEX_NAME
add_concurrent_foreign_key
:members
,
:namespaces
,
column: :member_namespace_id
,
on_delete: :nullify
,
reverse_lock_order:
true
end
def
down
with_lock_retries
do
remove_foreign_key_if_exists
:members
,
column: :member_namespace_id
end
remove_concurrent_index_by_name
:members
,
INDEX_NAME
end
end
db/schema_migrations/20220112232037
0 → 100644
View file @
4dae8709
775ac42ad194bd0175a6925e1c2e83c11d57a8d4430ad08a70e3d5275ca2e709
\ No newline at end of file
db/schema_migrations/20220112232605
0 → 100644
View file @
4dae8709
4813b55e933564851f2fec9a2fa5900409eff226fec34ae0be1895307f603904
\ No newline at end of file
db/structure.sql
View file @
4dae8709
...
@@ -15956,7 +15956,8 @@ CREATE TABLE members (
...
@@ -15956,7 +15956,8 @@ CREATE TABLE members (
ldap boolean DEFAULT false NOT NULL,
ldap boolean DEFAULT false NOT NULL,
override boolean DEFAULT false NOT NULL,
override boolean DEFAULT false NOT NULL,
state smallint DEFAULT 0,
state smallint DEFAULT 0,
invite_email_success boolean DEFAULT true NOT NULL
invite_email_success boolean DEFAULT true NOT NULL,
member_namespace_id bigint
);
);
CREATE SEQUENCE members_id_seq
CREATE SEQUENCE members_id_seq
...
@@ -26537,6 +26538,8 @@ CREATE INDEX index_members_on_invite_email ON members USING btree (invite_email)
...
@@ -26537,6 +26538,8 @@ CREATE INDEX index_members_on_invite_email ON members USING btree (invite_email)
CREATE UNIQUE INDEX index_members_on_invite_token ON members USING btree (invite_token);
CREATE UNIQUE INDEX index_members_on_invite_token ON members USING btree (invite_token);
CREATE INDEX index_members_on_member_namespace_id ON members USING btree (member_namespace_id);
CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at);
CREATE INDEX index_members_on_requested_at ON members USING btree (requested_at);
CREATE INDEX index_members_on_source_id_and_source_type ON members USING btree (source_id, source_type);
CREATE INDEX index_members_on_source_id_and_source_type ON members USING btree (source_id, source_type);
...
@@ -29554,6 +29557,9 @@ ALTER TABLE ONLY epics
...
@@ -29554,6 +29557,9 @@ ALTER TABLE ONLY epics
ALTER TABLE ONLY dast_profiles
ALTER TABLE ONLY dast_profiles
ADD CONSTRAINT fk_aa76ef30e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ADD CONSTRAINT fk_aa76ef30e9 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
ALTER TABLE ONLY members
ADD CONSTRAINT fk_aa82dcc1c6 FOREIGN KEY (member_namespace_id) REFERENCES namespaces(id) ON DELETE SET NULL;
ALTER TABLE ONLY alert_management_alerts
ALTER TABLE ONLY alert_management_alerts
ADD CONSTRAINT fk_aad61aedca FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL;
ADD CONSTRAINT fk_aad61aedca FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL;
spec/models/member_spec.rb
View file @
4dae8709
...
@@ -9,6 +9,7 @@ RSpec.describe Member do
...
@@ -9,6 +9,7 @@ RSpec.describe Member do
describe
'Associations'
do
describe
'Associations'
do
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
belong_to
(
:member_namespace
)
}
it
{
is_expected
.
to
have_one
(
:member_task
)
}
it
{
is_expected
.
to
have_one
(
:member_task
)
}
end
end
...
...
spec/models/namespace_spec.rb
View file @
4dae8709
...
@@ -29,6 +29,7 @@ RSpec.describe Namespace do
...
@@ -29,6 +29,7 @@ RSpec.describe Namespace do
it
{
is_expected
.
to
have_one
:admin_note
}
it
{
is_expected
.
to
have_one
:admin_note
}
it
{
is_expected
.
to
have_many
:pending_builds
}
it
{
is_expected
.
to
have_many
:pending_builds
}
it
{
is_expected
.
to
have_one
:namespace_route
}
it
{
is_expected
.
to
have_one
:namespace_route
}
it
{
is_expected
.
to
have_many
:namespace_members
}
describe
'#children'
do
describe
'#children'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment