seed_data_migrations 0.0.1.7 → 0.0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -651,7 +651,39 @@ module ActiveRecord
|
|
651
651
|
end
|
652
652
|
end
|
653
653
|
|
654
|
-
|
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
|
-
|
808
|
+
DataMigrationProxy.new(name, version, file, scope)
|
777
809
|
end
|
778
810
|
|
779
811
|
migrations.sort_by(&:version)
|