Sha256: be07a15e16fc2d18e302c8cc472813bf38999b27aa38254e9883a51e9b54cd9f
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
module Desert #:nodoc: module PluginMigrations class Migrator < ActiveRecord::Migrator class << self def current_version #:nodoc: if legacy_schema_table_exists? result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'") else result = nil end if result result['version'].to_i else # There probably isn't an entry for this plugin in the migration info table. 0 end end end def set_schema_version(version) version = down? ? version.to_i - 1 : version.to_i if self.class.legacy_schema_table_exists? if ActiveRecord::Base.connection.select_one("SELECT version FROM #{self.class.schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'").nil? # We need to create the entry since it doesn't exist ActiveRecord::Base.connection.execute("INSERT INTO #{self.class.schema_info_table_name} (version, plugin_name) VALUES (#{version},'#{current_plugin.name}')") else ActiveRecord::Base.connection.update("UPDATE #{self.class.schema_info_table_name} SET version = #{version} WHERE plugin_name = '#{current_plugin.name}'") end end end def migrated current_plugin_version = self.class.current_version (1..current_plugin_version).to_a end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
desert-0.5.4 | lib/desert/plugin_migrations/1.2/migrator.rb |