Skip to content
代码片段 群组 项目
未验证 提交 5502fd4a 编辑于 作者: Heinrich Lee Yu's avatar Heinrich Lee Yu
浏览文件

Add namespace_id to notes

This is going to be used for partitioning the table. Also prepares the
async index on the column so we can add the foreign key constraint to
this column.

Changelog: other
上级 6c57b734
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true
class AddNamespaceIdToNotes < Gitlab::Database::Migration[2.1]
enable_lock_retries!
def up
add_column :notes, :namespace_id, :bigint
end
def down
remove_column :notes, :namespace_id
end
end
# frozen_string_literal: true
class PrepareNotesNamespaceIdIndex < Gitlab::Database::Migration[2.1]
INDEX_NAME = 'index_notes_on_namespace_id'
# TODO: Index to be created synchronously as part of https://gitlab.com/gitlab-org/gitlab/-/issues/416127
def up
prepare_async_index :notes, :namespace_id, name: INDEX_NAME
end
def down
unprepare_async_index :notes, :namespace_id, name: INDEX_NAME
end
end
8cb2cd90109dcc4f29ab34fa4caca617fe7bf42493e3a6712b66978480f06940
\ No newline at end of file
636bd7305c03f94cd161dc21deda05c289946b31a3c04805c08273f9a7067729
\ No newline at end of file
...@@ -19080,7 +19080,8 @@ CREATE TABLE notes ( ...@@ -19080,7 +19080,8 @@ CREATE TABLE notes (
confidential boolean, confidential boolean,
last_edited_at timestamp with time zone, last_edited_at timestamp with time zone,
internal boolean DEFAULT false NOT NULL, internal boolean DEFAULT false NOT NULL,
id bigint NOT NULL id bigint NOT NULL,
namespace_id bigint
); );
   
CREATE SEQUENCE notes_id_seq CREATE SEQUENCE notes_id_seq
...@@ -984,9 +984,11 @@ excluded_attributes: ...@@ -984,9 +984,11 @@ excluded_attributes:
notes: notes:
- :noteable_id - :noteable_id
- :review_id - :review_id
- :namespace_id
commit_notes: commit_notes:
- :noteable_id - :noteable_id
- :review_id - :review_id
- :namespace_id
label_links: label_links:
- :label_id - :label_id
- :target_id - :target_id
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
# but in Search::NamespaceIndexAssignment model, only `search_index_id` is used as foreign key and indexed # but in Search::NamespaceIndexAssignment model, only `search_index_id` is used as foreign key and indexed
search_namespace_index_assignments: [%w[search_index_id index_type]], search_namespace_index_assignments: [%w[search_index_id index_type]],
slack_integrations_scopes: [%w[slack_api_scope_id]], slack_integrations_scopes: [%w[slack_api_scope_id]],
namespaces: %w[organization_id] # this index is added in an async manner, hence it needs to be ignored in the first phase. namespaces: %w[organization_id], # this index is added in an async manner, hence it needs to be ignored in the first phase.
notes: %w[namespace_id] # this index is added in an async manner, hence it needs to be ignored in the first phase.
}.with_indifferent_access.freeze }.with_indifferent_access.freeze
TABLE_PARTITIONS = %w[ci_builds_metadata].freeze TABLE_PARTITIONS = %w[ci_builds_metadata].freeze
...@@ -82,7 +83,7 @@ ...@@ -82,7 +83,7 @@
merge_requests_compliance_violations: %w[target_project_id], merge_requests_compliance_violations: %w[target_project_id],
merge_request_diff_commits: %w[commit_author_id committer_id], merge_request_diff_commits: %w[commit_author_id committer_id],
namespaces: %w[owner_id parent_id], namespaces: %w[owner_id parent_id],
notes: %w[author_id commit_id noteable_id updated_by_id resolved_by_id confirmed_by_id discussion_id], notes: %w[author_id commit_id noteable_id updated_by_id resolved_by_id confirmed_by_id discussion_id namespace_id],
notification_settings: %w[source_id], notification_settings: %w[source_id],
oauth_access_grants: %w[resource_owner_id application_id], oauth_access_grants: %w[resource_owner_id application_id],
oauth_access_tokens: %w[resource_owner_id application_id], oauth_access_tokens: %w[resource_owner_id application_id],
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册