Commit 051b027c authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 3ff35230 19235fa4
---
data_category: Optional
data_category: Standard
key_path: recorded_at
description: When the Usage Ping computation was started
product_section: growth
......
---
data_category: Optional
data_category: Standard
key_path: recording_ce_finished_at
description: When the core features were computed
product_section: growth
......
......@@ -12,21 +12,40 @@ description: "Learn how GitLab docs' global navigation works and how to add new
> - [Per-project](https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/498) navigation added in GitLab 12.2.
> - [Unified global navigation](https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/1482) added in GitLab 13.11.
Global navigation (the left-most pane in our three pane documentation) provides:
Global navigation is the left-most pane in the documentation. You can use the
"global nav" to browse the content.
- A high-level grouped view of product features.
- The ability to discover new features by browsing the menu structure.
- A way to allow the reader to focus on product areas.
- The ability to refine landing pages, so they don't have to do all the work of surfacing
every page contained within the documentation.
Research shows that people use Google to search for GitLab product documentation. When they land on a result,
we want them to find topics nearby that are related to the content they're reading. The global nav provides this information.
## Adding new items
At the highest level, our global nav is workflow-based. Navigation needs to help users build a mental model of how to use GitLab.
The levels under each of the higher workflow-based topics are the names of features.
For example:
**Use GitLab** (_workflow_) **> Build your application** (_workflow_) **> CI/CD** (_feature_) **> Pipelines** (_feature)
## Choose the right words for your navigation entry
Before you add an item to the left nav, choose the parts of speech you want to use.
The nav entry should match the page title. However, if the title is too long,
when you shorten the phrase, use either:
- A noun, like **Merge requests**.
- An active verb, like **Install GitLab** or **Get started with runners**.
Use a phrase that clearly indicates what the page is for. For example, **Get started** is not
as helpful as **Get started with runners**.
## Add a navigation entry
All topics should be included in the left nav.
To add a topic to the global nav, edit
[`navigation.yaml`](https://gitlab.com/gitlab-org/gitlab-docs/blob/main/content/_data/navigation.yaml)
and add your item.
All new pages need a new navigation item. Without a navigation, the page becomes "orphaned". That
All new pages need a navigation item. Without a navigation, the page becomes "orphaned." That
is:
- The navigation shuts when the page is opened, and the reader loses their place.
......@@ -93,7 +112,7 @@ for clarity.
To see the improvements planned, check the
[global nav epic](https://gitlab.com/groups/gitlab-org/-/epics/1599).
**Do not** [add items](#adding-new-items) to the global nav without
**Do not** [add items](#add-a-navigation-entry) to the global nav without
the consent of one of the technical writers.
## Composition
......
......@@ -8974,7 +8974,7 @@ When the Usage Ping computation was started
Group: `group::product intelligence`
Data Category: `Optional`
Data Category: `Standard`
Status: `data_available`
......@@ -8988,7 +8988,7 @@ When the core features were computed
Group: `group::product intelligence`
Data Category: `Optional`
Data Category: `Standard`
Status: `data_available`
......@@ -9002,7 +9002,7 @@ When the EE-specific features were computed
Group: `group::product intelligence`
Data Category: `Subscription`
Data Category: `Standard`
Status: `data_available`
......
......@@ -9,7 +9,7 @@ value_type: string
status: data_available
time_frame: none
data_source: system
data_category: Subscription
data_category: Standard
distribution:
- ee
tier:
......
......@@ -217,11 +217,12 @@ module Gitlab
# source - The source table containing the foreign key.
# target - The target table the key points to.
# column - The name of the column to create the foreign key on.
# target_column - The name of the referenced column, defaults to "id".
# on_delete - The action to perform when associated data is removed,
# defaults to "CASCADE".
# name - The name of the foreign key.
#
def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil, validate: true)
def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, target_column: :id, name: nil, validate: true)
# Transactions would result in ALTER TABLE locks being held for the
# duration of the transaction, defeating the purpose of this method.
if transaction_open?
......@@ -231,7 +232,8 @@ module Gitlab
options = {
column: column,
on_delete: on_delete,
name: name.presence || concurrent_foreign_key_name(source, column)
name: name.presence || concurrent_foreign_key_name(source, column),
primary_key: target_column
}
if foreign_key_exists?(source, target, **options)
......@@ -252,7 +254,7 @@ module Gitlab
ALTER TABLE #{source}
ADD CONSTRAINT #{options[:name]}
FOREIGN KEY (#{options[:column]})
REFERENCES #{target} (id)
REFERENCES #{target} (#{target_column})
#{on_delete_statement(options[:on_delete])}
NOT VALID;
EOF
......
......@@ -379,6 +379,37 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
allow(model).to receive(:transaction_open?).and_return(false)
end
context 'target column' do
it 'defaults to (id) when no custom target column is provided' do
expect(model).to receive(:with_lock_retries).and_call_original
expect(model).to receive(:disable_statement_timeout).and_call_original
expect(model).to receive(:statement_timeout_disabled?).and_return(false)
expect(model).to receive(:execute).with(/statement_timeout/)
expect(model).to receive(:execute).ordered.with(/VALIDATE CONSTRAINT/)
expect(model).to receive(:execute).ordered.with(/RESET ALL/)
expect(model).to receive(:execute).with(/REFERENCES users \(id\)/)
model.add_concurrent_foreign_key(:projects, :users,
column: :user_id)
end
it 'references the custom taget column when provided' do
expect(model).to receive(:with_lock_retries).and_call_original
expect(model).to receive(:disable_statement_timeout).and_call_original
expect(model).to receive(:statement_timeout_disabled?).and_return(false)
expect(model).to receive(:execute).with(/statement_timeout/)
expect(model).to receive(:execute).ordered.with(/VALIDATE CONSTRAINT/)
expect(model).to receive(:execute).ordered.with(/RESET ALL/)
expect(model).to receive(:execute).with(/REFERENCES users \(id_convert_to_bigint\)/)
model.add_concurrent_foreign_key(:projects, :users,
column: :user_id,
target_column: :id_convert_to_bigint)
end
end
context 'ON DELETE statements' do
context 'on_delete: :nullify' do
it 'appends ON DELETE SET NULL statement' do
......@@ -450,7 +481,8 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
expect(model).to receive(:foreign_key_exists?).with(:projects, :users,
column: :user_id,
on_delete: :cascade,
name: name).and_return(true)
name: name,
primary_key: :id).and_return(true)
expect(model).not_to receive(:execute).with(/ADD CONSTRAINT/)
expect(model).to receive(:execute).with(/VALIDATE CONSTRAINT/)
......@@ -479,6 +511,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
it 'does not create a new foreign key' do
expect(model).to receive(:foreign_key_exists?).with(:projects, :users,
name: :foo,
primary_key: :id,
on_delete: :cascade,
column: :user_id).and_return(true)
......@@ -583,7 +616,15 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
describe '#foreign_key_exists?' do
before do
key = ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(:projects, :users, { column: :non_standard_id, name: :fk_projects_users_non_standard_id, on_delete: :cascade })
key = ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(
:projects, :users,
{
column: :non_standard_id,
name: :fk_projects_users_non_standard_id,
on_delete: :cascade,
primary_key: :id
}
)
allow(model).to receive(:foreign_keys).with(:projects).and_return([key])
end
......@@ -612,6 +653,11 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
expect(model.foreign_key_exists?(:projects, target_table, column: :user_id)).to be_falsey
end
it 'compares by target column name if given' do
expect(model.foreign_key_exists?(:projects, target_table, primary_key: :user_id)).to be_falsey
expect(model.foreign_key_exists?(:projects, target_table, primary_key: :id)).to be_truthy
end
it 'compares by foreign key name if given' do
expect(model.foreign_key_exists?(:projects, target_table, name: :non_existent_foreign_key_name)).to be_falsey
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