Sha256: 450e87e31a901b35f6c07eb56088d29a4d1803473b989397d915a0785dfbbf52
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
class ActiveRecord::Migration module DesertMigration def migrate_plugin(plugin_name, version) plugin = find_plugin(plugin_name) Desert::PluginMigrations::Migrator.migrate_plugin( plugin, version ) end def schema_version_equivalent_to(plugin_name, version) plugin = find_plugin(plugin_name) Desert::PluginMigrations::Migrator.current_plugin = plugin Desert::PluginMigrations::Migrator.allocate.set_schema_version(version) end protected def find_plugin(plugin_name) plugin = Desert::Manager.find_plugin(plugin_name.to_s) return plugin if plugin raise ArgumentError, "No plugin found named #{plugin_name}" end def table_exists?(table_name) vals = select_all("DESC #{table_name}") return true rescue ActiveRecord::StatementInvalid return false end def column_exists?(table_name, column_name) val = select_one("select #{column_name} from #{table_name}") return true rescue ActiveRecord::StatementInvalid return false end def table_exists?(table_name) ActiveRecord::Base.connection.tables.include? table_name end end extend DesertMigration end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
desert-0.2.2 | lib/desert/rails/migration.rb |
desert-0.3.0 | lib/desert/rails/migration.rb |