debian-mirror-gitlab/db/migrate/20200430130048_create_packages_nuget_metadata.rb

37 lines
1.3 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
class CreatePackagesNugetMetadata < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
LICENSE_URL_CONSTRAINT_NAME = 'packages_nuget_metadata_license_url_constraint'
PROJECT_URL_CONSTRAINT_NAME = 'packages_nuget_metadata_project_url_constraint'
ICON_URL_CONSTRAINT_NAME = 'packages_nuget_metadata_icon_url_constraint'
def up
unless table_exists?(:packages_nuget_metadata)
with_lock_retries do
create_table :packages_nuget_metadata, id: false do |t|
t.references :package, primary_key: true, default: nil, index: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :bigint
t.text :license_url
t.text :project_url
t.text :icon_url
end
end
end
add_text_limit :packages_nuget_metadata, :license_url, 255, constraint_name: LICENSE_URL_CONSTRAINT_NAME
add_text_limit :packages_nuget_metadata, :project_url, 255, constraint_name: PROJECT_URL_CONSTRAINT_NAME
add_text_limit :packages_nuget_metadata, :icon_url, 255, constraint_name: ICON_URL_CONSTRAINT_NAME
end
def down
2020-06-23 00:09:42 +05:30
# rubocop:disable Migration/DropTable
2020-05-24 23:13:21 +05:30
drop_table :packages_nuget_metadata
2020-06-23 00:09:42 +05:30
# rubocop:enable Migration/DropTable
2020-05-24 23:13:21 +05:30
end
end