Class: Radiant::ExtensionMigrator

Inherits:
ActiveRecord::Migrator
  • Object
show all
Defined in:
lib/radiant/extension_migrator.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(direction, migrations_path, target_version = nil) ⇒ ExtensionMigrator

Returns a new instance of ExtensionMigrator.



23
24
25
26
# File 'lib/radiant/extension_migrator.rb', line 23

def initialize(direction, migrations_path, target_version = nil)
  super
  initialize_extension_schema_migrations
end

Class Attribute Details

.extensionObject

Returns the value of attribute extension.



4
5
6
# File 'lib/radiant/extension_migrator.rb', line 4

def extension
  @extension
end

Class Method Details

.get_all_versionsObject



16
17
18
19
20
# File 'lib/radiant/extension_migrator.rb', line 16

def get_all_versions
  ActiveRecord::Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name}").
    select { |version| version.starts_with?("#{@extension.extension_name}-")}.
    map { |version| version.sub("#{@extension.extension_name}-", '').to_i }.sort
end

.migrate(target_version = nil) ⇒ Object



6
7
8
# File 'lib/radiant/extension_migrator.rb', line 6

def migrate(target_version = nil)
  super extension.migrations_path, target_version
end

.migrate_extensionsObject



10
11
12
13
14
# File 'lib/radiant/extension_migrator.rb', line 10

def migrate_extensions
  Extension.descendants.each do |ext|
    ext.migrator.migrate
  end
end