Save pages_deployments path_prefix and build.ref
What does this MR do and why?
Save pages_deployments path_prefix and build.ref
As part of the GitLab Pages Multiple Versions Support1,
we need to add path_prefix
and build_ref
to PagesDeployment:
- the path_prefix will be used to build the versioned url
- the ref (git reference) will be used to clear deployments when the ref is deleted (branch/tag)
New pages builds must save the build.ref in the PagesDeployment#ref column.
Related to: #416488 (closed)
Changelog: added
Migrations
bundle exec rails db:migrate:up:main VERSION=20230809165212
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 96251
main: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: migrating =======
main: -- add_column(:pages_deployments, :path_prefix, :text)
main: -> 0.0012s
main: -- add_column(:pages_deployments, :build_ref, :text)
main: -> 0.0004s
main: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: migrated (0.0046s)
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 96251
bundle exec rails db:migrate:up:ci VERSION=20230809165212
ci: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 96816
ci: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: migrating =======
ci: -- add_column(:pages_deployments, :path_prefix, :text)
ci: -> 0.0016s
ci: -- add_column(:pages_deployments, :build_ref, :text)
ci: -> 0.0005s
ci: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: migrated (0.0106s)
ci: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 96816
bundle exec rails db:migrate:up:main VERSION=20230809165213
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 97412
main: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: migrating
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE pages_deployments\nADD CONSTRAINT check_4d04b8dc9a\nCHECK ( char_length(path_prefix) <= 128 )\nNOT VALID;\n")
main: -> 0.0041s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0002s
main: -- execute("ALTER TABLE pages_deployments VALIDATE CONSTRAINT check_4d04b8dc9a;")
main: -> 0.0030s
main: -- execute("RESET statement_timeout")
main: -> 0.0002s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute("ALTER TABLE pages_deployments\nADD CONSTRAINT check_b44e900e5c\nCHECK ( char_length(build_ref) <= 512 )\nNOT VALID;\n")
main: -> 0.0004s
main: -- execute("ALTER TABLE pages_deployments VALIDATE CONSTRAINT check_b44e900e5c;")
main: -> 0.0025s
main: -- transaction_open?()
main: -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main: -> 0.0027s
main: -- index_exists?(:pages_deployments, [:project_id, :path_prefix], {:name=>"index_pages_deployments_unique_path_prefix_by_project", :unique=>true, :algorithm=>:concurrently})
main: -> 0.0087s
main: -- add_index(:pages_deployments, [:project_id, :path_prefix], {:name=>"index_pages_deployments_unique_path_prefix_by_project", :unique=>true, :algorithm=>:concurrently})
main: -> 0.0046s
main: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: migrated (0.2992s)
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 97412
bundle exec rails db:migrate:up:ci VERSION=20230809165213
ci: == [advisory_lock_connection] object_id: 224660, pg_backend_pid: 97962
ci: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: migrating
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- execute("ALTER TABLE pages_deployments\nADD CONSTRAINT check_4d04b8dc9a\nCHECK ( char_length(path_prefix) <= 128 )\nNOT VALID;\n")
ci: -> 0.0009s
ci: -- execute("SET statement_timeout TO 0")
ci: -> 0.0003s
ci: -- execute("ALTER TABLE pages_deployments VALIDATE CONSTRAINT check_4d04b8dc9a;")
ci: -> 0.0044s
ci: -- execute("RESET statement_timeout")
ci: -> 0.0003s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- execute("ALTER TABLE pages_deployments\nADD CONSTRAINT check_b44e900e5c\nCHECK ( char_length(build_ref) <= 512 )\nNOT VALID;\n")
ci: -> 0.0006s
ci: -- execute("ALTER TABLE pages_deployments VALIDATE CONSTRAINT check_b44e900e5c;")
ci: -> 0.0004s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci: -> 0.0006s
ci: -- index_exists?(:pages_deployments, [:project_id, :path_prefix], {:name=>"index_pages_deployments_unique_path_prefix_by_project", :unique=>true, :algorithm=>:concurrently})
ci: -> 0.0662s
ci: -- add_index(:pages_deployments, [:project_id, :path_prefix], {:name=>"index_pages_deployments_unique_path_prefix_by_project", :unique=>true, :algorithm=>:concurrently})
ci: -> 0.0028s
ci: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: migrated (0.3815s)
ci: == [advisory_lock_connection] object_id: 224660, pg_backend_pid: 97962
bundle exec rails db:migrate:down:main VERSION=20230809165213
main: == [advisory_lock_connection] object_id: 224660, pg_backend_pid: 93878
main: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: reverting
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute(" ALTER TABLE pages_deployments\n DROP CONSTRAINT IF EXISTS check_4d04b8dc9a\n")
main: -> 0.0007s
main: -- transaction_open?()
main: -> 0.0000s
main: -- transaction_open?()
main: -> 0.0000s
main: -- execute(" ALTER TABLE pages_deployments\n DROP CONSTRAINT IF EXISTS check_b44e900e5c\n")
main: -> 0.0003s
main: -- transaction_open?()
main: -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main: -> 0.1074s
main: -- indexes(:pages_deployments)
main: -> 0.0028s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0001s
main: -- remove_index(:pages_deployments, {:algorithm=>:concurrently, :name=>"index_pages_deployments_unique_path_prefix_by_project"})
main: -> 0.0016s
main: -- execute("RESET statement_timeout")
main: -> 0.0003s
main: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: reverted (0.1347s)
main: == [advisory_lock_connection] object_id: 224660, pg_backend_pid: 93878
bundle exec rails db:migrate:down:ci VERSION=20230809165213
ci: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 94464
ci: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: reverting
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- execute(" ALTER TABLE pages_deployments\n DROP CONSTRAINT IF EXISTS check_4d04b8dc9a\n")
ci: -> 0.0008s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- execute(" ALTER TABLE pages_deployments\n DROP CONSTRAINT IF EXISTS check_b44e900e5c\n")
ci: -> 0.0003s
ci: -- transaction_open?()
ci: -> 0.0000s
ci: -- view_exists?(:postgres_partitions)
ci: -> 0.1249s
ci: -- indexes(:pages_deployments)
ci: -> 0.0028s
ci: -- execute("SET statement_timeout TO 0")
ci: -> 0.0002s
ci: -- remove_index(:pages_deployments, {:algorithm=>:concurrently, :name=>"index_pages_deployments_unique_path_prefix_by_project"})
ci: -> 0.0015s
ci: -- execute("RESET statement_timeout")
ci: -> 0.0002s
ci: == 20230809165213 AddIndexToPathPrefixAndBuildRefToPagesDeployments: reverted (0.1601s)
ci: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 94464
bundle exec rails db:migrate:down:main VERSION=20230809165212
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 95026
main: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: reverting =======
main: -- remove_column(:pages_deployments, :build_ref, :text)
main: -> 0.0017s
main: -- remove_column(:pages_deployments, :path_prefix, :text)
main: -> 0.0004s
main: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: reverted (0.0072s)
main: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 95026
bundle exec rails db:migrate:down:ci VERSION=20230809165212
ci: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 95590
ci: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: reverting =======
ci: -- remove_column(:pages_deployments, :build_ref, :text)
ci: -> 0.0012s
ci: -- remove_column(:pages_deployments, :path_prefix, :text)
ci: -> 0.0003s
ci: == 20230809165212 AddPathPrefixAndBuildRefToPagesDeployments: reverted (0.0107s)
ci: == [advisory_lock_connection] object_id: 224600, pg_backend_pid: 95590
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.
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 Kassio Borges