Save pages build artifact id in pages metadata
What does this MR do?
Part of #238986 (closed).
This MR saves job_artifacts_archive.id in pages metadata which will later be used in !40361 (merged)
Database Migrations
Up
$ bundle exec rails db:migrate:up VERSION=20200827102234
== 20200827102234 AddCiJobArtifactIdToPagesMetadata: migrating ================
-- add_column(:project_pages_metadata, :artifacts_archive_id, :bigint)
-> 0.0014s
== 20200827102234 AddCiJobArtifactIdToPagesMetadata: migrated (0.0015s) =======
$ bundle exec rails db:migrate:up VERSION=20200827104432
== 20200827104432 AddForeignKeyToArtifactsArchiveIdInPagesMetadata: migrating =
-- transaction_open?()
-> 0.0000s
-- index_exists?(:project_pages_metadata, :artifacts_archive_id, {:algorithm=>:concurrently})
-> 0.0029s
-- add_index(:project_pages_metadata, :artifacts_archive_id, {:algorithm=>:concurrently})
-> 0.0053s
-- transaction_open?()
-> 0.0000s
-- foreign_keys(:project_pages_metadata)
-> 0.0039s
-- execute("ALTER TABLE project_pages_metadata\nADD CONSTRAINT fk_69366a119e\nFOREIGN KEY (artifacts_archive_id)\nREFERENCES ci_job_artifacts (id)\nON DELETE SET NULL\nNOT VALID;\n")
-> 0.0038s
-- execute("ALTER TABLE project_pages_metadata VALIDATE CONSTRAINT fk_69366a119e;")
-> 0.0029s
== 20200827104432 AddForeignKeyToArtifactsArchiveIdInPagesMetadata: migrated (0.0248s)
Down
$ bundle exec rails db:migrate:down VERSION=20200827104432
== 20200827104432 AddForeignKeyToArtifactsArchiveIdInPagesMetadata: reverting =
-- foreign_keys(:project_pages_metadata)
-> 0.0037s
-- remove_foreign_key(:project_pages_metadata, :ci_job_artifacts, {:column=>:artifacts_archive_id})
-> 0.0043s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:project_pages_metadata, :artifacts_archive_id, {:algorithm=>:concurrently})
-> 0.0031s
-- remove_index(:project_pages_metadata, {:algorithm=>:concurrently, :column=>:artifacts_archive_id})
-> 0.0040s
== 20200827104432 AddForeignKeyToArtifactsArchiveIdInPagesMetadata: reverted (0.0158s)
$ bundle exec rails db:migrate:down VERSION=20200827102234
== 20200827102234 AddCiJobArtifactIdToPagesMetadata: reverting ================
-- remove_column(:project_pages_metadata, :artifacts_archive_id, :bigint)
-> 0.0015s
== 20200827102234 AddCiJobArtifactIdToPagesMetadata: reverted (0.0056s) =======
Creating Index
On #database-lab
(https://gitlab.slack.com/archives/CLJMDRD8C/p1598569547168900, internal):
exec CREATE INDEX CONCURRENTLY ON project_pages_metadata(artifacts_archive_id)
The query has been executed. Duration: 42.235 s (edited)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Kamil Trzciński