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:
commit
4e846c735f
|
@ -20,7 +20,7 @@ class CleanupMoveSystemUploadFolderSymlink < ActiveRecord::Migration
|
||||||
def down
|
def down
|
||||||
if File.directory?(new_directory)
|
if File.directory?(new_directory)
|
||||||
say "Symlinking #{old_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
|
else
|
||||||
say "#{new_directory} doesn't exist, skipping."
|
say "#{new_directory} doesn't exist, skipping."
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
require 'spec_helper'
|
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
|
include TrackUntrackedUploadsHelpers
|
||||||
|
|
||||||
subject { described_class.new }
|
subject { described_class.new }
|
||||||
|
|
|
@ -3,10 +3,14 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_project_names.rb')
|
require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_project_names.rb')
|
||||||
|
|
||||||
# This migration uses multiple threads, and thus different transactions. This
|
# This migration is using factories, which set fields that don't actually
|
||||||
# means data created in this spec may not be visible to some threads. To work
|
# exist in the DB schema previous to 20161221153951. Thus we just use the
|
||||||
# around this we use the DELETE cleaning strategy.
|
# latest schema when testing this migration.
|
||||||
describe RenameReservedProjectNames, :delete do
|
# 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(:migration) { described_class.new }
|
||||||
let!(:project) { create(:project) }
|
let!(:project) { create(:project) }
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,13 @@ module MigrationsHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
def migration_schema_version
|
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
|
end
|
||||||
|
|
||||||
def schema_migrate_down!
|
def schema_migrate_down!
|
||||||
|
@ -58,6 +64,8 @@ module MigrationsHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
def schema_migrate_up!
|
def schema_migrate_up!
|
||||||
|
reset_column_in_all_models
|
||||||
|
|
||||||
disable_migrations_output do
|
disable_migrations_output do
|
||||||
ActiveRecord::Migrator.migrate(migrations_paths)
|
ActiveRecord::Migrator.migrate(migrations_paths)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue