Merge branch 'sh-no-cache-populate-migration' into 'master'

Disable caching of tables for migration spec that drops a temporary table

See merge request gitlab-org/gitlab-ce!16965
This commit is contained in:
Sean McGivern 2018-02-13 10:33:14 +00:00
commit 4e846c735f
4 changed files with 24 additions and 7 deletions

View File

@ -20,7 +20,7 @@ class CleanupMoveSystemUploadFolderSymlink < ActiveRecord::Migration
def down
if File.directory?(new_directory)
say "Symlinking #{old_directory} -> #{new_directory}"
FileUtils.ln_s(new_directory, old_directory)
FileUtils.ln_s(new_directory, old_directory) unless File.exist?(old_directory)
else
say "#{new_directory} doesn't exist, skipping."
end

View File

@ -1,6 +1,11 @@
require 'spec_helper'
describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq do
# This migration is using UploadService, which sets uploads.secret that is only
# added to the DB schema in 20180129193323. Since the test isn't isolated, we
# just use the latest schema when testing this migration.
# Ideally, the test should not use factories nor UploadService, and rely on the
# `table` helper instead.
describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migration, schema: 20180129193323 do
include TrackUntrackedUploadsHelpers
subject { described_class.new }

View File

@ -3,10 +3,14 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_project_names.rb')
# This migration uses multiple threads, and thus different transactions. This
# means data created in this spec may not be visible to some threads. To work
# around this we use the DELETE cleaning strategy.
describe RenameReservedProjectNames, :delete do
# This migration is using factories, which set fields that don't actually
# exist in the DB schema previous to 20161221153951. Thus we just use the
# latest schema when testing this migration.
# This is ok-ish because:
# 1. This migration is a data migration
# 2. It only relies on very stable DB fields: routes.id, routes.path, namespaces.id, projects.namespace_id
# Ideally, the test should not use factories and rely on the `table` helper instead.
describe RenameReservedProjectNames, :migration, schema: :latest do
let(:migration) { described_class.new }
let!(:project) { create(:project) }

View File

@ -45,7 +45,13 @@ module MigrationsHelpers
end
def migration_schema_version
self.class.metadata[:schema] || previous_migration.version
metadata_schema = self.class.metadata[:schema]
if metadata_schema == :latest
migrations.last.version
else
metadata_schema || previous_migration.version
end
end
def schema_migrate_down!
@ -58,6 +64,8 @@ module MigrationsHelpers
end
def schema_migrate_up!
reset_column_in_all_models
disable_migrations_output do
ActiveRecord::Migrator.migrate(migrations_paths)
end