Commit e8b1ed53 authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Adds creator_id field to packages table

- adds creator_id field
- adds index on creator_id
- adds fk to users table
parent 525ee153
---
title: Adds creator_id field to 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
...@@ -13965,7 +13965,8 @@ CREATE TABLE public.packages_packages ( ...@@ -13965,7 +13965,8 @@ CREATE TABLE public.packages_packages (
updated_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL,
name character varying NOT NULL, name character varying NOT NULL,
version character varying, version character varying,
package_type smallint NOT NULL package_type smallint NOT NULL,
creator_id integer
); );
CREATE SEQUENCE public.packages_packages_id_seq CREATE SEQUENCE public.packages_packages_id_seq
...@@ -20339,6 +20340,8 @@ CREATE INDEX index_packages_package_files_on_file_store ON public.packages_packa ...@@ -20339,6 +20340,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_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_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); CREATE INDEX index_packages_packages_on_project_id_and_created_at ON public.packages_packages USING btree (project_id, created_at);
...@@ -21911,6 +21914,9 @@ ALTER TABLE ONLY public.ci_builds ...@@ -21911,6 +21914,9 @@ ALTER TABLE ONLY public.ci_builds
ALTER TABLE ONLY public.design_management_versions ALTER TABLE ONLY public.design_management_versions
ADD CONSTRAINT fk_c1440b4896 FOREIGN KEY (author_id) REFERENCES public.users(id) ON DELETE SET NULL; 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 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; 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