Skip to content

Rename ci_pipeline_metadata.title to name

Reuben Pereira requested to merge rp/pipeline-title-rename-to-name into master

What does this MR do and why?

Describe in detail what your merge request does and why.

Rename the title column in ci_pipeline_metadata table to name. This column will be used to store pipeline names. The column is not being used currently. The MR to start using the column is !97502 (merged), which was merged this week. The feature flag has not been enabled though, so the column is not being used yet. gitlab.com has 0 rows in the ci_pipeline_metadata table. The table itself was added in the 15.5 milestone (!97139 (merged)).

We had originally decided to call the column and the attribute in the .gitlab-ci.yml file title, but in the discussion at !97502 (comment 1126897321), we decided to go with name to stay consistent with job names.

Migration output:
main: == 20221017084208 RenameCiPipelineMetadataTitle: migrating ====================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- columns(:ci_pipeline_metadata)
main:    -> 0.0049s
main: -- column_exists?(:ci_pipeline_metadata, :pipeline_id)
main:    -> 0.0020s
main: -- column_exists?(:ci_pipeline_metadata, :name)
main:    -> 0.0018s
main: -- columns(:ci_pipeline_metadata)
main:    -> 0.0019s
main: -- add_column(:ci_pipeline_metadata, :name, :text, {:limit=>nil, :precision=>nil, :scale=>nil})
main:    -> 0.0080s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- exec_query("SELECT COUNT(*) AS count FROM \"ci_pipeline_metadata\"")
main:    -> 0.0010s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1")
main:    -> 0.0007s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 156 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0006s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0010s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"name\" = \"ci_pipeline_metadata\".\"title\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 156 AND \"ci_pipeline_metadata\".\"pipeline_id\" < 159")
main:    -> 0.0007s
main:    -> 0.0040s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 159 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0008s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0009s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"name\" = \"ci_pipeline_metadata\".\"title\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 159 AND \"ci_pipeline_metadata\".\"pipeline_id\" < 160")
main:    -> 0.0006s
main:    -> 0.0027s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 160 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0007s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0009s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"name\" = \"ci_pipeline_metadata\".\"title\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 160 AND \"ci_pipeline_metadata\".\"pipeline_id\" < 161")
main:    -> 0.0006s
main:    -> 0.0025s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 161 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0006s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0009s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"name\" = \"ci_pipeline_metadata\".\"title\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 161")
main:    -> 0.0005s
main:    -> 0.0023s
main: -- indexes(:ci_pipeline_metadata)
main:    -> 0.0054s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:ci_pipeline_metadata, ["pipeline_id", "name"], {:unique=>false, :name=>"index_ci_pipeline_metadata_on_pipeline_id_name", :length=>{}, :order=>{}, :using=>:btree, :algorithm=>:concurrently})
main:    -> 0.0036s
main: -- add_index(:ci_pipeline_metadata, ["pipeline_id", "name"], {:unique=>false, :name=>"index_ci_pipeline_metadata_on_pipeline_id_name", :length=>{}, :order=>{}, :using=>:btree, :algorithm=>:concurrently})
main:    -> 0.0039s
main: -- foreign_keys(:ci_pipeline_metadata)
main:    -> 0.0040s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- column_exists?(:ci_pipeline_metadata, :title)
main:    -> 0.0022s
main: -- column_exists?(:ci_pipeline_metadata, :name)
main:    -> 0.0020s
main: -- current_schema()
main:    -> 0.0004s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- current_schema()
main:    -> 0.0006s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE ci_pipeline_metadata\nADD CONSTRAINT check_25d23931f1\nCHECK ( (name IS NOT NULL) )\nNOT VALID;\n")
main:    -> 0.0008s
main: -- current_schema()
main:    -> 0.0004s
main: -- execute("ALTER TABLE ci_pipeline_metadata VALIDATE CONSTRAINT check_25d23931f1;")
main:    -> 0.0010s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- current_schema()
main:    -> 0.0004s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE ci_pipeline_metadata\nADD CONSTRAINT check_9d3665463c\nCHECK ( (char_length(name) <= 255) )\nNOT VALID;\n")
main:    -> 0.0007s
main: -- current_schema()
main:    -> 0.0003s
main: -- execute("ALTER TABLE ci_pipeline_metadata VALIDATE CONSTRAINT check_9d3665463c;")
main:    -> 0.0013s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- quote_table_name(:ci_pipeline_metadata)
main:    -> 0.0000s
main: -- quote_column_name(:title)
main:    -> 0.0000s
main: -- quote_column_name(:name)
main:    -> 0.0000s
main: -- execute("CREATE OR REPLACE FUNCTION function_for_trigger_5ea69df84db9()\nRETURNS trigger\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  IF NEW.\"title\" IS NULL AND NEW.\"name\" IS NOT NULL THEN\n    NEW.\"title\" = NEW.\"name\";\n  END IF;\n\n  IF NEW.\"name\" IS NULL AND NEW.\"title\" IS NOT NULL THEN\n    NEW.\"name\" = NEW.\"title\";\n  END IF;\n\n  RETURN NEW;\nEND\n$$;\n\nDROP TRIGGER IF EXISTS trigger_5ea69df84db9\nON \"ci_pipeline_metadata\";\n\nCREATE TRIGGER trigger_5ea69df84db9\nBEFORE INSERT ON \"ci_pipeline_metadata\"\nFOR EACH ROW EXECUTE FUNCTION function_for_trigger_5ea69df84db9();\n")
main:    -> 0.0016s
main: -- execute("CREATE OR REPLACE FUNCTION function_for_trigger_4d1e05e0275c()\nRETURNS trigger\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  NEW.\"title\" := NEW.\"name\";\n  RETURN NEW;\nEND\n$$;\n\nDROP TRIGGER IF EXISTS trigger_4d1e05e0275c\nON \"ci_pipeline_metadata\";\n\nCREATE TRIGGER trigger_4d1e05e0275c\nBEFORE UPDATE OF \"name\" ON \"ci_pipeline_metadata\"\nFOR EACH ROW EXECUTE FUNCTION function_for_trigger_4d1e05e0275c();\n")
main:    -> 0.0008s
main: -- execute("CREATE OR REPLACE FUNCTION function_for_trigger_f292e497df78()\nRETURNS trigger\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  NEW.\"name\" := NEW.\"title\";\n  RETURN NEW;\nEND\n$$;\n\nDROP TRIGGER IF EXISTS trigger_f292e497df78\nON \"ci_pipeline_metadata\";\n\nCREATE TRIGGER trigger_f292e497df78\nBEFORE UPDATE OF \"title\" ON \"ci_pipeline_metadata\"\nFOR EACH ROW EXECUTE FUNCTION function_for_trigger_f292e497df78();\n")
main:    -> 0.0007s
main: == 20221017084208 RenameCiPipelineMetadataTitle: migrated (0.1004s) ===========

main: == 20221017084227 CleanupRenameCiPipelineMetadataTitle: migrating =============
main: -- column_exists?(:ci_pipeline_metadata, :title)
main:    -> 0.0019s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- quote_table_name(:ci_pipeline_metadata)
main:    -> 0.0000s
main: -- execute("DROP TRIGGER IF EXISTS trigger_5ea69df84db9\nON \"ci_pipeline_metadata\";\n\nDROP FUNCTION IF EXISTS function_for_trigger_5ea69df84db9;\n")
main:    -> 0.0008s
main: -- execute("DROP TRIGGER IF EXISTS trigger_4d1e05e0275c\nON \"ci_pipeline_metadata\";\n\nDROP FUNCTION IF EXISTS function_for_trigger_4d1e05e0275c;\n")
main:    -> 0.0007s
main: -- execute("DROP TRIGGER IF EXISTS trigger_f292e497df78\nON \"ci_pipeline_metadata\";\n\nDROP FUNCTION IF EXISTS function_for_trigger_f292e497df78;\n")
main:    -> 0.0006s
main: -- remove_column(:ci_pipeline_metadata, :title)
main:    -> 0.0009s
main: == 20221017084227 CleanupRenameCiPipelineMetadataTitle: migrated (0.0085s) ====
Revert output:
main: == 20221017084227 CleanupRenameCiPipelineMetadataTitle: reverting =============
main: -- transaction_open?()
main:    -> 0.0000s
main: -- columns(:ci_pipeline_metadata)
main:    -> 0.0048s
main: -- column_exists?(:ci_pipeline_metadata, :pipeline_id)
main:    -> 0.0019s
main: -- column_exists?(:ci_pipeline_metadata, :title)
main:    -> 0.0017s
main: -- columns(:ci_pipeline_metadata)
main:    -> 0.0019s
main: -- add_column(:ci_pipeline_metadata, :title, :text, {:limit=>nil, :precision=>nil, :scale=>nil})
main:    -> 0.0016s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- exec_query("SELECT COUNT(*) AS count FROM \"ci_pipeline_metadata\"")
main:    -> 0.0009s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1")
main:    -> 0.0007s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 156 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0006s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0010s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"title\" = \"ci_pipeline_metadata\".\"name\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 156 AND \"ci_pipeline_metadata\".\"pipeline_id\" < 159")
main:    -> 0.0006s
main:    -> 0.0036s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 159 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0005s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0007s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"title\" = \"ci_pipeline_metadata\".\"name\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 159 AND \"ci_pipeline_metadata\".\"pipeline_id\" < 160")
main:    -> 0.0005s
main:    -> 0.0020s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 160 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0005s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0008s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"title\" = \"ci_pipeline_metadata\".\"name\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 160 AND \"ci_pipeline_metadata\".\"pipeline_id\" < 161")
main:    -> 0.0005s
main:    -> 0.0021s
main: -- exec_query("SELECT \"ci_pipeline_metadata\".\"pipeline_id\" FROM \"ci_pipeline_metadata\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 161 ORDER BY \"ci_pipeline_metadata\".\"pipeline_id\" ASC LIMIT 1 OFFSET 1")
main:    -> 0.0005s
main: -- transaction()
main: -- execute("SELECT set_config('lock_writes.ci_pipeline_metadata', 'false', true)")
main:    -> 0.0008s
main: -- execute("UPDATE \"ci_pipeline_metadata\" SET \"title\" = \"ci_pipeline_metadata\".\"name\" WHERE \"ci_pipeline_metadata\".\"pipeline_id\" >= 161")
main:    -> 0.0006s
main:    -> 0.0024s
main: -- indexes(:ci_pipeline_metadata)
main:    -> 0.0044s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- index_exists?(:ci_pipeline_metadata, ["pipeline_id", "title"], {:unique=>false, :name=>"index_ci_pipeline_metadata_on_pipeline_id_title", :length=>{}, :order=>{}, :using=>:btree, :algorithm=>:concurrently})
main:    -> 0.0042s
main: -- add_index(:ci_pipeline_metadata, ["pipeline_id", "title"], {:unique=>false, :name=>"index_ci_pipeline_metadata_on_pipeline_id_title", :length=>{}, :order=>{}, :using=>:btree, :algorithm=>:concurrently})
main:    -> 0.0063s
main: -- foreign_keys(:ci_pipeline_metadata)
main:    -> 0.0042s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- column_exists?(:ci_pipeline_metadata, :name)
main:    -> 0.0020s
main: -- column_exists?(:ci_pipeline_metadata, :title)
main:    -> 0.0018s
main: -- current_schema()
main:    -> 0.0005s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- current_schema()
main:    -> 0.0005s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE ci_pipeline_metadata\nADD CONSTRAINT check_aa44a73891\nCHECK ( (title IS NOT NULL) )\nNOT VALID;\n")
main:    -> 0.0007s
main: -- current_schema()
main:    -> 0.0004s
main: -- execute("ALTER TABLE ci_pipeline_metadata VALIDATE CONSTRAINT check_aa44a73891;")
main:    -> 0.0014s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- current_schema()
main:    -> 0.0003s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE ci_pipeline_metadata\nADD CONSTRAINT check_e6a636a3f3\nCHECK ( (char_length(title) <= 255) )\nNOT VALID;\n")
main:    -> 0.0006s
main: -- current_schema()
main:    -> 0.0004s
main: -- execute("ALTER TABLE ci_pipeline_metadata VALIDATE CONSTRAINT check_e6a636a3f3;")
main:    -> 0.0012s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- quote_table_name(:ci_pipeline_metadata)
main:    -> 0.0000s
main: -- quote_column_name(:title)
main:    -> 0.0000s
main: -- quote_column_name(:name)
main:    -> 0.0000s
main: -- execute("CREATE OR REPLACE FUNCTION function_for_trigger_5ea69df84db9()\nRETURNS trigger\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  IF NEW.\"title\" IS NULL AND NEW.\"name\" IS NOT NULL THEN\n    NEW.\"title\" = NEW.\"name\";\n  END IF;\n\n  IF NEW.\"name\" IS NULL AND NEW.\"title\" IS NOT NULL THEN\n    NEW.\"name\" = NEW.\"title\";\n  END IF;\n\n  RETURN NEW;\nEND\n$$;\n\nDROP TRIGGER IF EXISTS trigger_5ea69df84db9\nON \"ci_pipeline_metadata\";\n\nCREATE TRIGGER trigger_5ea69df84db9\nBEFORE INSERT ON \"ci_pipeline_metadata\"\nFOR EACH ROW EXECUTE FUNCTION function_for_trigger_5ea69df84db9();\n")
main:    -> 0.0017s
main: -- execute("CREATE OR REPLACE FUNCTION function_for_trigger_4d1e05e0275c()\nRETURNS trigger\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  NEW.\"title\" := NEW.\"name\";\n  RETURN NEW;\nEND\n$$;\n\nDROP TRIGGER IF EXISTS trigger_4d1e05e0275c\nON \"ci_pipeline_metadata\";\n\nCREATE TRIGGER trigger_4d1e05e0275c\nBEFORE UPDATE OF \"name\" ON \"ci_pipeline_metadata\"\nFOR EACH ROW EXECUTE FUNCTION function_for_trigger_4d1e05e0275c();\n")
main:    -> 0.0009s
main: -- execute("CREATE OR REPLACE FUNCTION function_for_trigger_f292e497df78()\nRETURNS trigger\nLANGUAGE plpgsql\nAS $$\nBEGIN\n  NEW.\"name\" := NEW.\"title\";\n  RETURN NEW;\nEND\n$$;\n\nDROP TRIGGER IF EXISTS trigger_f292e497df78\nON \"ci_pipeline_metadata\";\n\nCREATE TRIGGER trigger_f292e497df78\nBEFORE UPDATE OF \"title\" ON \"ci_pipeline_metadata\"\nFOR EACH ROW EXECUTE FUNCTION function_for_trigger_f292e497df78();\n")
main:    -> 0.0009s
main: == 20221017084227 CleanupRenameCiPipelineMetadataTitle: reverted (0.1008s) ====

main: == 20221017084208 RenameCiPipelineMetadataTitle: reverting ====================
main: -- column_exists?(:ci_pipeline_metadata, :name)
main:    -> 0.0057s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- quote_table_name(:ci_pipeline_metadata)
main:    -> 0.0000s
main: -- execute("DROP TRIGGER IF EXISTS trigger_5ea69df84db9\nON \"ci_pipeline_metadata\";\n\nDROP FUNCTION IF EXISTS function_for_trigger_5ea69df84db9;\n")
main:    -> 0.0012s
main: -- execute("DROP TRIGGER IF EXISTS trigger_4d1e05e0275c\nON \"ci_pipeline_metadata\";\n\nDROP FUNCTION IF EXISTS function_for_trigger_4d1e05e0275c;\n")
main:    -> 0.0009s
main: -- execute("DROP TRIGGER IF EXISTS trigger_f292e497df78\nON \"ci_pipeline_metadata\";\n\nDROP FUNCTION IF EXISTS function_for_trigger_f292e497df78;\n")
main:    -> 0.0008s
main: -- remove_column(:ci_pipeline_metadata, :name)
main:    -> 0.0018s
main: == 20221017084208 RenameCiPipelineMetadataTitle: reverted (0.0233s) ===========

#372538 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Michael Kozono

Merge request reports

Loading