Commit 76047be5 authored by Sean McGivern's avatar Sean McGivern

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

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

See merge request gitlab-org/gitlab-ee!4420
parents 6e2a8af2 fc8ef3b5
......@@ -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
......
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 }
......
......@@ -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) }
......
......@@ -47,7 +47,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!
......@@ -60,6 +66,8 @@ module MigrationsHelpers
end
def schema_migrate_up!
reset_column_in_all_models
disable_migrations_output do
ActiveRecord::Migrator.migrate(migrations_paths)
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