Skip to content

Resolve "Create new merge_request_diff_llm_summary table"

What does this MR do and why?

We have the following epic &10401 (closed) that represents the version 2 of the feature. This involves creating the summary automatically, and storing it in the database, rather than the current approach of a note.

This adds the database portion to store the data.

Related to #408274 (closed)

!118671 (comment 1369305286)

Roll back

➜  gitlab git:(408274-create-new-merge_request_diff_llm_summary-table) bundle exec rake db:rollback:main
main: == [advisory_lock_connection] object_id: 274360, pg_backend_pid: 24845
main: == 20230426161341 AddMergeRequestDiffForeignKeyToMergeRequestDiffLlmSummary: reverting
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:merge_request_diff_llm_summaries, {:column=>:merge_request_diff_id})
main:    -> 0.1057s
main: == 20230426161341 AddMergeRequestDiffForeignKeyToMergeRequestDiffLlmSummary: reverted (0.1335s)

main: == [advisory_lock_connection] object_id: 274360, pg_backend_pid: 24845
➜  gitlab git:(408274-create-new-merge_request_diff_llm_summary-table) ✗ bundle exec rake db:rollback:main
main: == [advisory_lock_connection] object_id: 274260, pg_backend_pid: 25237
main: == 20230426161259 AddUserForeignKeyToMergeRequestDiffLlmSummary: reverting ====
main: -- transaction_open?()
main:    -> 0.0000s
main: -- remove_foreign_key(:merge_request_diff_llm_summaries, {:column=>:user_id})
main:    -> 0.0496s
main: == 20230426161259 AddUserForeignKeyToMergeRequestDiffLlmSummary: reverted (0.0635s)

main: == [advisory_lock_connection] object_id: 274260, pg_backend_pid: 25237
➜  gitlab git:(408274-create-new-merge_request_diff_llm_summary-table) ✗ bundle exec rake db:rollback:main
main: == [advisory_lock_connection] object_id: 274260, pg_backend_pid: 26032
main: == 20230425173111 CreateMergeRequestDiffLlmSummary: reverting =================
main: -- drop_table(:merge_request_diff_llm_summaries)
main:    -> 0.0028s
main: == 20230425173111 CreateMergeRequestDiffLlmSummary: reverted (0.0076s) ========

main: == [advisory_lock_connection] object_id: 274260, pg_backend_pid: 26032

Migrate

➜  gitlab git:(408274-create-new-merge_request_diff_llm_summary-table) ✗ bundle exec
 rake db:migrate
main: == [advisory_lock_connection] object_id: 274520, pg_backend_pid: 26488
main: == 20230425173111 CreateMergeRequestDiffLlmSummary: migrating =================
main: -- create_table(:merge_request_diff_llm_summaries)
main: -- quote_column_name(:content)
main:    -> 0.0000s
main:    -> 0.0086s
main: == 20230425173111 CreateMergeRequestDiffLlmSummary: migrated (0.0560s) ========

main: == 20230426161259 AddUserForeignKeyToMergeRequestDiffLlmSummary: migrating ====
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE merge_request_diff_llm_summaries ADD CONSTRAINT fk_42551b9fea FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT VALID;")
main:    -> 0.0023s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0002s
main: -- execute("ALTER TABLE merge_request_diff_llm_summaries VALIDATE CONSTRAINT fk_42551b9fea;")
main:    -> 0.0120s
main: -- execute("RESET statement_timeout")
main:    -> 0.0004s
main: == 20230426161259 AddUserForeignKeyToMergeRequestDiffLlmSummary: migrated (0.0377s)

main: == 20230426161341 AddMergeRequestDiffForeignKeyToMergeRequestDiffLlmSummary: migrating
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE merge_request_diff_llm_summaries ADD CONSTRAINT fk_e98931c3cb FOREIGN KEY (merge_request_diff_id) REFERENCES merge_request_diffs (id) ON DELETE CASCADE NOT VALID;")
main:    -> 0.0024s
main: -- execute("ALTER TABLE merge_request_diff_llm_summaries VALIDATE CONSTRAINT fk_e98931c3cb;")
main:    -> 0.0051s
main: == 20230426161341 AddMergeRequestDiffForeignKeyToMergeRequestDiffLlmSummary: migrated (0.0712s)

main: == [advisory_lock_connection] object_id: 274520, pg_backend_pid: 26488
Edited by Marc Shaw

Merge request reports

Loading