Skip to content

Adds creator_id field to packages table

Giorgenes Gelatti requested to merge 205578-add-creator-id-to-packages into master

What does this MR do?

Adds creator_id fields to the packages table and index it.

This is gonna be used in for counting in the usage data. We want to track the count of unique users publishing packages.

So a follow up MR will populate this field when creating packages and then we can do the aggragate queries on that data.

Migrations (Up)

== 20200827005322 AddCreatorIdToPackages: migrating ===========================
-- add_column(:packages_packages, :creator_id, :integer)
   -> 0.0015s
== 20200827005322 AddCreatorIdToPackages: migrated (0.0016s) ==================

== 20200830201204 AddIndexToPackageCreator: migrating =========================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:packages_packages, :creator_id, {:name=>"index_packages_packages_on_creator_id", :algorithm=>:concurrently})
   -> 0.0118s
-- add_index(:packages_packages, :creator_id, {:name=>"index_packages_packages_on_creator_id", :algorithm=>:concurrently})
   -> 0.2132s
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:packages_packages)
   -> 0.0242s
-- execute("ALTER TABLE packages_packages\nADD CONSTRAINT fk_c188f0dba4\nFOREIGN KEY (creator_id)\nREFERENCES users (id)\nON DELETE SET NULL\nNOT VALID;\n")
   -> 0.2436s
-- execute("ALTER TABLE packages_packages VALIDATE CONSTRAINT fk_c188f0dba4;")
   -> 0.0758s
== 20200830201204 AddIndexToPackageCreator: migrated (0.6002s) ================

Migration (down)

== 20200830201204 AddIndexToPackageCreator: reverting =========================
-- foreign_keys(:packages_packages)
   -> 0.0048s
-- remove_foreign_key(:packages_packages, :users, {:column=>:creator_id})
   -> 0.0084s
-- transaction_open?()
   -> 0.0000s
-- indexes(:packages_packages)
   -> 0.0088s
-- remove_index(:packages_packages, {:algorithm=>:concurrently, :name=>"index_packages_packages_on_creator_id"})
   -> 0.0027s
== 20200830201204 AddIndexToPackageCreator: reverted (0.0260s) ================

== 20200827005322 AddCreatorIdToPackages: reverting ===========================
-- remove_column(:packages_packages, :creator_id, :integer)
   -> 0.0060s
== 20200827005322 AddCreatorIdToPackages: reverted (0.0086s) ==================

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

Part of #205578 (closed)

Edited by Giorgenes Gelatti

Merge request reports