Commit d19f509f authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Adds composer.json to composer metadata in db

Adding the composer.json metadata to db for
quick access when retrieving it while
serving composer packages.
parent df71d756
# frozen_string_literal: true
class AddComposerJsonToMetadata < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :packages_composer_metadata, :composer_json, :jsonb, default: {}, null: false
end
end
......@@ -4672,7 +4672,8 @@ ALTER SEQUENCE public.packages_build_infos_id_seq OWNED BY public.packages_build
CREATE TABLE public.packages_composer_metadata (
package_id bigint NOT NULL,
target_sha bytea NOT NULL
target_sha bytea NOT NULL,
composer_json jsonb DEFAULT '{}'::jsonb NOT NULL
);
CREATE TABLE public.packages_conan_file_metadata (
......@@ -13971,5 +13972,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200609142507
20200609142508
20200609212701
20200615083635
\.
......@@ -8,7 +8,7 @@ module Packages
belongs_to :package, -> { where(package_type: :composer) }, inverse_of: :composer_metadatum
validates :package, presence: true
validates :package, :target_sha, :composer_json, presence: true
end
end
end
......@@ -12,7 +12,8 @@ module Packages
::Packages::Package.transaction do
::Packages::Composer::Metadatum.upsert(
package_id: created_package.id,
target_sha: target
target_sha: target,
composer_json: composer_json
)
end
end
......
---
title: Save composer.json to package metadata
merge_request: 34494
author:
type: performance
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Packages::Composer::Metadatum, type: :model do
describe 'relationships' do
it { is_expected.to belong_to(:package) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:package) }
it { is_expected.to validate_presence_of(:target_sha) }
it { is_expected.to validate_presence_of(:composer_json) }
end
end
......@@ -34,6 +34,8 @@ describe Packages::Composer::CreatePackageService do
expect(created_package.name).to eq package_name
expect(created_package.version).to eq 'dev-master'
expect(created_package.composer_metadatum.target_sha).to eq branch.target
expect(created_package.composer_metadatum.composer_json.to_json).to eq json
end
end
......
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