aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-10-08 21:17:14 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-10-09 21:32:34 +0200
commit4377f8eba2dde51fe5d3bc50248c0089e24c8d24 (patch)
tree21d105bbca5110d3faee9e759a0ea2c607252c1c /activerecord/lib
parent5d5eb2b18d364cb27d2062668bd3b1921b1040a8 (diff)
downloadrails-4377f8eba2dde51fe5d3bc50248c0089e24c8d24.tar.gz
rails-4377f8eba2dde51fe5d3bc50248c0089e24c8d24.tar.bz2
rails-4377f8eba2dde51fe5d3bc50248c0089e24c8d24.zip
Change the method for copying migrations, do not add scope.
The purpose of this change is to allow copying fail on the same names. Migrations change database and they should be treated with caution, if 2 migrations are named the same it's much better to skip migration and allow user decide if it should be copied or not.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/migration.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 9ac18f9939..3fc69d7af0 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -387,18 +387,18 @@ module ActiveRecord
def copy(destination, sources)
copied = []
- sources.each do |scope, path|
+ sources.each do |name, path|
destination_migrations = ActiveRecord::Migrator.migrations(destination)
source_migrations = ActiveRecord::Migrator.migrations(path)
last = destination_migrations.last
source_migrations.each do |migration|
- next if destination_migrations.any? { |m| m.name == migration.name && m.scope == scope.to_s }
+ next if destination_migrations.any? { |m| m.name == migration.name }
migration.version = next_migration_number(last ? last.version + 1 : 0).to_i
last = migration
- new_path = File.join(destination, "#{migration.version}_#{migration.name.underscore}.#{scope}.rb")
+ new_path = File.join(destination, "#{migration.version}_#{migration.name.underscore}.rb")
FileUtils.cp(migration.filename, new_path)
copied << new_path
end
@@ -419,9 +419,9 @@ module ActiveRecord
# MigrationProxy is used to defer loading of the actual migration classes
# until they are needed
- class MigrationProxy < Struct.new(:name, :version, :filename, :scope)
+ class MigrationProxy < Struct.new(:name, :version, :filename)
- def initialize(name, version, filename, scope)
+ def initialize(name, version, filename)
super
@migration = nil
end
@@ -510,18 +510,18 @@ module ActiveRecord
seen = Hash.new false
migrations = files.map do |file|
- version, name, scope = file.scan(/([0-9]+)_([_a-z0-9]*)\.?([_a-z0-9]*)?.rb/).first
+ version, name = file.scan(/([0-9]+)_([_a-z0-9]*).rb/).first
raise IllegalMigrationNameError.new(file) unless version
version = version.to_i
name = name.camelize
raise DuplicateMigrationVersionError.new(version) if seen[version]
- raise DuplicateMigrationNameError.new(name) if seen[[name, scope]]
+ raise DuplicateMigrationNameError.new(name) if seen[name]
- seen[version] = seen[[name, scope]] = true
+ seen[version] = seen[name] = true
- MigrationProxy.new(name, version, file, scope)
+ MigrationProxy.new(name, version, file)
end
migrations.sort_by(&:version)