Commit 33e67127 authored by Yannis Roussos's avatar Yannis Roussos

Merge branch '205578-add-creator-id-to-packages' into 'master'

Adds creator_id field to packages table

See merge request gitlab-org/gitlab!40562
parents a6fd5753 769d4110
---
title: Adds creator_id field to packages_packages table
merge_request: 40562
author:
type: other
# frozen_string_literal: true
class AddCreatorIdToPackages < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column(:packages_packages, :creator_id, :integer)
end
end
# frozen_string_literal: true
class AddIndexToPackageCreator < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
INDEX_NAME = 'index_packages_packages_on_creator_id'
def up
add_concurrent_index :packages_packages, :creator_id, name: INDEX_NAME
add_concurrent_foreign_key(:packages_packages, :users, column: :creator_id, on_delete: :nullify)
end
def down
remove_foreign_key_if_exists(:packages_packages, :users, column: :creator_id)
remove_concurrent_index_by_name(:packages_packages, INDEX_NAME)
end
end
f4f1efcc93476a1d70add93e166f4c702ad7dfc97ad29c3455722fd98824498f
\ No newline at end of file
1e8dd4542b13009b748d352933a4a59fcabb31e916226fcbf87043396f94e09f
\ No newline at end of file
......@@ -14025,7 +14025,8 @@ CREATE TABLE public.packages_packages (
updated_at timestamp with time zone NOT NULL,
name character varying NOT NULL,
version character varying,
package_type smallint NOT NULL
package_type smallint NOT NULL,
creator_id integer
);
CREATE SEQUENCE public.packages_packages_id_seq
......@@ -20457,6 +20458,8 @@ CREATE INDEX index_packages_package_files_on_file_store ON public.packages_packa
CREATE INDEX index_packages_package_files_on_package_id_and_file_name ON public.packages_package_files USING btree (package_id, file_name);
CREATE INDEX index_packages_packages_on_creator_id ON public.packages_packages USING btree (creator_id);
CREATE INDEX index_packages_packages_on_name_trigram ON public.packages_packages USING gin (name public.gin_trgm_ops);
CREATE INDEX index_packages_packages_on_project_id_and_created_at ON public.packages_packages USING btree (project_id, created_at);
......@@ -22039,6 +22042,9 @@ ALTER TABLE ONLY public.ci_builds
ALTER TABLE ONLY public.design_management_versions
ADD CONSTRAINT fk_c1440b4896 FOREIGN KEY (author_id) REFERENCES public.users(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.packages_packages
ADD CONSTRAINT fk_c188f0dba4 FOREIGN KEY (creator_id) REFERENCES public.users(id) ON DELETE SET NULL;
ALTER TABLE ONLY public.geo_event_log
ADD CONSTRAINT fk_c1f241c70d FOREIGN KEY (upload_deleted_event_id) REFERENCES public.geo_upload_deleted_events(id) ON DELETE CASCADE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment