Sha256: fdae94dd1b2b99bf99bda2e6cac0774f13bb19c1e8502cf5ad041a89fb0e71a2
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
module PluginAWeek #:nodoc: module PluginMigrations # Responsible for migrating plugins. +current_plugin+ indicates which plugin # is currently being migrated. class Migrator < ActiveRecord::Migrator # We need to be able to set the current plugin being migrated cattr_accessor :current_plugin class << self # Runs the migrations from a plugin, up (or down) to the version given def migrate_plugin(plugin, version = nil) self.current_plugin = plugin migrate(plugin.migration_path, version) end def schema_info_table_name #:nodoc: ActiveRecord::Base.table_name_prefix + 'plugin_schema_info' + ActiveRecord::Base.table_name_suffix end def current_version #:nodoc: current_plugin.current_version end end # Sets the version of the current plugin def set_schema_version(version) version = down? ? version.to_i - 1 : version.to_i if ActiveRecord::Base.connection.select_one("SELECT version FROM #{self.class.schema_info_table_name} WHERE plugin_name = '#{current_plugin.name}'") ActiveRecord::Base.connection.update("UPDATE #{self.class.schema_info_table_name} SET version = #{version} WHERE plugin_name = '#{current_plugin.name}'") else # 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}')") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
plugin_migrations-0.1.2 | lib/plugin_migrations/migrator.rb |