Skip to content
Snippets Groups Projects
Unverified Commit 4cdf123e authored by Laura Montemayor's avatar Laura Montemayor Committed by GitLab
Browse files

Merge branch '490377-rename-component-model-column' into 'master'

parents a8e006e3 5b3f3f59
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6,6 +6,9 @@ module Resources
# This class represents a CI/CD Catalog resource component.
# The data will be used as metadata of a component.
class Component < ::ApplicationRecord
include IgnorableColumns
ignore_column :resource_type, remove_with: '17.8', remove_after: '2024-11-18'
self.table_name = 'catalog_resource_components'
 
belongs_to :project, inverse_of: :ci_components
Loading
Loading
@@ -17,7 +20,7 @@ class Component < ::ApplicationRecord
# an error about the save callback that is auto generated for this association.
include BulkInsertSafe
 
enum resource_type: { template: 1 }
enum component_type: { template: 1 }
 
validates :spec, json_schema: { filename: 'catalog_resource_component_spec' }
validates :version, :catalog_resource, :project, :name, presence: true
Loading
Loading
Loading
Loading
@@ -89,7 +89,7 @@ def build_catalog_resource_component(metadata)
name: metadata[:name],
project: version.project,
spec: metadata[:spec],
resource_type: metadata[:component_type], # https://gitlab.com/gitlab-org/gitlab/-/issues/490377
component_type: metadata[:component_type],
version: version,
catalog_resource: version.catalog_resource,
created_at: Time.current
Loading
Loading
# frozen_string_literal: true
class RenameComponentResourceTypeToComponentType < Gitlab::Database::Migration[2.2]
disable_ddl_transaction!
milestone '17.6'
def up
rename_column_concurrently :catalog_resource_components, :resource_type, :component_type
end
def down
undo_rename_column_concurrently :catalog_resource_components, :resource_type, :component_type
end
end
# frozen_string_literal: true
class CleanupResourceTypeRename < Gitlab::Database::Migration[2.2]
disable_ddl_transaction!
milestone '17.6'
def up
cleanup_concurrent_column_rename :catalog_resource_components, :resource_type, :component_type
end
def down
undo_cleanup_concurrent_column_rename :catalog_resource_components, :resource_type, :component_type
end
end
374a47bc55f32bfacf702b20bf3da4ca3afe9563b4594965d87138af2eb3644d
\ No newline at end of file
8f5e9d7f091626b0d36a626756bad1550c007ee621a8890c0c2f8f710fc2151c
\ No newline at end of file
Loading
Loading
@@ -8142,11 +8142,12 @@ CREATE TABLE catalog_resource_components (
version_id bigint NOT NULL,
project_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
resource_type smallint DEFAULT 1 NOT NULL,
name text NOT NULL,
spec jsonb DEFAULT '{}'::jsonb NOT NULL,
last_30_day_usage_count integer DEFAULT 0 NOT NULL,
last_30_day_usage_count_updated_at timestamp with time zone DEFAULT '1970-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
component_type smallint DEFAULT 1,
CONSTRAINT check_47c5537132 CHECK ((component_type IS NOT NULL)),
CONSTRAINT check_ddca729980 CHECK ((char_length(name) <= 255))
);
 
Loading
Loading
@@ -25,7 +25,7 @@ def track_event(component)
user: current_user,
additional_properties: {
label: component.id.to_s,
value: component.resource_type_before_type_cast
value: component.component_type_before_type_cast
}
)
 
Loading
Loading
Loading
Loading
@@ -96,7 +96,7 @@
{ 'inputs' => { 'world' => { 'default' => 'abc' } } }
]
)
expect(components.map(&:resource_type)).to all(eq('template'))
expect(components.map(&:component_type)).to all(eq('template'))
end
 
context 'when the release was already published' do
Loading
Loading
Loading
Loading
@@ -86,7 +86,7 @@
response = execute
 
expect(response).to be_error
expect(response.message).to include("'invalid' is not a valid resource_type")
expect(response.message).to include("'invalid' is not a valid component_type")
end
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment