Commit ceabf5a8 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Add table for storing issue tsvector

This will be used for full-text search. We store the tsvector in a
column instead of computing it from the issue columns because we need to
transform the data in Ruby before generating the tsvector.

Changelog: other
parent c2440e5e
# frozen_string_literal: true
class CreateIssueSearchTable < Gitlab::Database::Migration[1.0]
def change
create_table :issue_search_data, id: false do |t|
t.references :issue, index: false, default: nil, primary_key: true, foreign_key: { on_delete: :cascade }, type: :bigint
t.timestamps_with_timezone default: -> { 'CURRENT_TIMESTAMP' }
t.tsvector :search_vector
t.index :search_vector, using: :gin, name: 'index_issue_search_data_on_search_vector'
end
end
end
9d87052305a552ce380e81a33c690496c44e332eb86869ea6882f5cd4856ab93
\ No newline at end of file
......@@ -15655,6 +15655,13 @@ CREATE SEQUENCE issue_metrics_id_seq
ALTER SEQUENCE issue_metrics_id_seq OWNED BY issue_metrics.id;
CREATE TABLE issue_search_data (
issue_id bigint NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
search_vector tsvector
);
CREATE TABLE issue_tracker_data (
id bigint NOT NULL,
service_id integer NOT NULL,
......@@ -23711,6 +23718,9 @@ ALTER TABLE ONLY issue_links
ALTER TABLE ONLY issue_metrics
ADD CONSTRAINT issue_metrics_pkey PRIMARY KEY (id);
ALTER TABLE ONLY issue_search_data
ADD CONSTRAINT issue_search_data_pkey PRIMARY KEY (issue_id);
ALTER TABLE ONLY issue_tracker_data
ADD CONSTRAINT issue_tracker_data_pkey PRIMARY KEY (id);
......@@ -26693,6 +26703,8 @@ CREATE INDEX index_issue_metrics_on_issue_id_and_timestamps ON issue_metrics USI
CREATE INDEX index_issue_on_project_id_state_id_and_blocking_issues_count ON issues USING btree (project_id, state_id, blocking_issues_count);
CREATE INDEX index_issue_search_data_on_search_vector ON issue_search_data USING gin (search_vector);
CREATE INDEX index_issue_tracker_data_on_service_id ON issue_tracker_data USING btree (service_id);
CREATE UNIQUE INDEX index_issue_user_mentions_on_note_id ON issue_user_mentions USING btree (note_id) WHERE (note_id IS NOT NULL);
......@@ -31431,6 +31443,9 @@ ALTER TABLE ONLY operations_strategies_user_lists
ALTER TABLE ONLY issue_tracker_data
ADD CONSTRAINT fk_rails_ccc0840427 FOREIGN KEY (service_id) REFERENCES integrations(id) ON DELETE CASCADE;
ALTER TABLE ONLY issue_search_data
ADD CONSTRAINT fk_rails_ce5f26b01c FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
ALTER TABLE ONLY resource_milestone_events
ADD CONSTRAINT fk_rails_cedf8cce4d FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
......@@ -272,6 +272,7 @@ issue_emails: :gitlab_main
issue_email_participants: :gitlab_main
issue_links: :gitlab_main
issue_metrics: :gitlab_main
issue_search_data: :gitlab_main
issues: :gitlab_main
issues_prometheus_alert_events: :gitlab_main
issues_self_managed_prometheus_alert_events: :gitlab_main
......
......@@ -34,6 +34,7 @@ issues:
- issuable_severity
- issuable_sla
- issue_assignees
- search_data
- closed_by
- epic_issue
- epic
......@@ -627,6 +628,8 @@ issuable_severity:
issue_assignees:
- issue
- assignee
search_data:
- issue
merge_request_assignees:
- merge_request
- assignee
......
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