Sha256: f4a05cd6a5f2712be65b31dfb4f49ceff7fa7fa0ca905b17e4c1aec4b6b9fbb1
Contents?: true
Size: 963 Bytes
Versions: 8
Compression:
Stored size: 963 Bytes
Contents
module DataMigrate # Helper class to getting access to db schema # to allow data/schema combiation tasks class SchemaMigration def self.pending_schema_migrations all_migrations = ActiveRecord::MigrationContext.new(migrations_paths).migrations sort_migrations( ActiveRecord::Migrator.new(:up, all_migrations). pending_migrations. map {|m| { version: m.version, kind: :schema }} ) end def self.run(direction, migration_paths, version) ActiveRecord::MigrationContext.new(migration_paths).run(direction, version) end def self.sort_migrations(set1, set2 = nil) migrations = set1 + (set2 || []) migrations.sort {|a, b| sort_string(a) <=> sort_string(b)} end def self.migrations_paths Rails.application.config.paths["db/migrate"].to_a end def self.sort_string(migration) "#{migration[:version]}_#{migration[:kind] == :data ? 1 : 0}" end end end
Version data entries
8 entries across 8 versions & 1 rubygems