Migration to add root_namespace_id to project_statistics
What does this MR do and why?
Adds new column root_namespace_id to project_statistics table
Ref: #424728 (closed)
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Database Migration
Up
ci: == [advisory_lock_connection] object_id: 343100, pg_backend_pid: 69750
main: == [advisory_lock_connection] object_id: 344140, pg_backend_pid: 69753
main: == 20230911095016 AddRootNamespaceIdToProjectStatistics: migrating ============
main: -- column_exists?(:project_statistics, :root_namespace_id)
main: -> 0.0022s
main: -- add_column(:project_statistics, :root_namespace_id, :bigint)
main: -> 0.0005s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE project_statistics ADD CONSTRAINT fk_198ad46fdc FOREIGN KEY (root_namespace_id) REFERENCES namespaces (id) ON DELETE SET NULL NOT VALID;")
main: -> 0.0017s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0001s
main: -- execute("ALTER TABLE project_statistics VALIDATE CONSTRAINT fk_198ad46fdc;")
main: -> 0.0050s
main: -- execute("RESET statement_timeout")
main: -> 0.0002s
main: -- transaction_open?()
main: -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main: -> 0.0005s
main: -- index_exists?(:project_statistics, :root_namespace_id, {:name=>"index_project_statistics_on_root_namespace_id", :algorithm=>:concurrently})
main: -> 0.0038s
main: -- add_index(:project_statistics, :root_namespace_id, {:name=>"index_project_statistics_on_root_namespace_id", :algorithm=>:concurrently})
main: -> 0.0009s
main: == 20230911095016 AddRootNamespaceIdToProjectStatistics: migrated (0.0328s) ===
main: == [advisory_lock_connection] object_id: 344140, pg_backend_pid: 69753
Down
main: == [advisory_lock_connection] object_id: 226120, pg_backend_pid: 71785
main: == 20230911095016 AddRootNamespaceIdToProjectStatistics: reverting ============
main: -- remove_column(:project_statistics, :root_namespace_id, :bigint)
main: -> 0.0018s
main: == 20230911095016 AddRootNamespaceIdToProjectStatistics: reverted (0.0081s) ===
main: == [advisory_lock_connection] object_id: 226120, pg_backend_pid: 71785
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Suraj Tripathi