seed_data_migrations 0.0.1.7 → 0.0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -651,7 +651,39 @@ module ActiveRecord
651
651
  end
652
652
  end
653
653
 
654
- class NullDataMigration < MigrationProxy #:nodoc:
654
+ # MigrationProxy is used to defer loading of the actual migration classes
655
+ # until they are needed
656
+ class DataMigrationProxy < Struct.new(:name, :version, :filename, :scope)
657
+
658
+ def initialize(name, version, filename, scope)
659
+ super
660
+ @migration = nil
661
+ end
662
+
663
+ def basename
664
+ File.basename(filename)
665
+ end
666
+
667
+ def mtime
668
+ File.mtime filename
669
+ end
670
+
671
+ delegate :migrate, :announce, :write, :disable_ddl_transaction, to: :migration
672
+
673
+ private
674
+
675
+ def migration
676
+ @migration ||= load_migration
677
+ end
678
+
679
+ def load_migration
680
+ require(File.expand_path(filename))
681
+ name.constantize.new(name, version)
682
+ end
683
+
684
+ end
685
+
686
+ class NullDataMigration < DataMigrationProxy #:nodoc:
655
687
  def initialize
656
688
  super(nil, 0, nil, nil)
657
689
  end
@@ -773,7 +805,7 @@ module ActiveRecord
773
805
  version = version.to_i
774
806
  name = name.camelize
775
807
 
776
- MigrationProxy.new(name, version, file, scope)
808
+ DataMigrationProxy.new(name, version, file, scope)
777
809
  end
778
810
 
779
811
  migrations.sort_by(&:version)
@@ -1,3 +1,3 @@
1
1
  module SeedDataMigrations
2
- VERSION = "0.0.1.7"
2
+ VERSION = "0.0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seed_data_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.7
4
+ version: 0.0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: