Commit 540dface authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Make package migrations reversible

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 78514b79
......@@ -5,7 +5,7 @@ class CreatePackagesPackageFiles < ActiveRecord::Migration
disable_ddl_transaction!
def change
def up
create_table :packages_package_files do |t|
t.references :package, index: true, null: false
t.string :file
......@@ -23,4 +23,14 @@ class CreatePackagesPackageFiles < ActiveRecord::Migration
column: :package_id,
on_delete: :cascade
end
def down
if foreign_keys_for(:packages_package_files, :package_id).any?
remove_foreign_key :packages_package_files, column: :package_id
end
if table_exists?(:packages_package_files)
drop_table :packages_package_files
end
end
end
......@@ -5,7 +5,7 @@ class CreatePackagesMavenMetadata < ActiveRecord::Migration
disable_ddl_transaction!
def change
def up
create_table :packages_maven_metadata do |t|
t.references :package, index: true, null: false
t.string :app_group, null: false
......@@ -19,4 +19,14 @@ class CreatePackagesMavenMetadata < ActiveRecord::Migration
column: :package_id,
on_delete: :cascade
end
def down
if foreign_keys_for(:packages_maven_metadata, :package_id).any?
remove_foreign_key :packages_maven_metadata, column: :package_id
end
if table_exists?(:packages_maven_metadata)
drop_table :packages_maven_metadata
end
end
end
......@@ -123,8 +123,8 @@ describe API::MavenPackages do
it 'creates package and stores package file' do
expect { upload_file_with_token(params) }.to change { project.packages.count }.by(1)
#.and change { Packages::MavenMetadatum.count }.by(1)
#.and change { Packages::PackageFile.count }.by(1)
.and change { Packages::MavenMetadatum.count }.by(1)
.and change { Packages::PackageFile.count }.by(1)
expect(response).to have_gitlab_http_status(200)
expect(package_file.original_filename).to eq(file_upload.original_filename)
......
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