Class: PluginMigrator::VersionHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/plugin_migrator/version_helper.rb

Instance Method Summary collapse

Instance Method Details

#add_version(version_number) ⇒ Object



6
7
8
# File 'lib/plugin_migrator/version_helper.rb', line 6

def add_version(version_number)
  ActiveRecord::Base.connection.execute("INSERT INTO schema_migrations (version) VALUES ('#{version_number}')")
end

#remove_version(version_number) ⇒ Object



10
11
12
# File 'lib/plugin_migrator/version_helper.rb', line 10

def remove_version(version_number)
  ActiveRecord::Base.connection.execute("DELETE FROM schema_migrations WHERE version = '#{version_number}'")
end

#version_exists?(version_number) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/plugin_migrator/version_helper.rb', line 2

def version_exists?(version_number)
  ActiveRecord::Base.connection.execute("SELECT * FROM schema_migrations WHERE version = '#{version_number}' LIMIT 1").any?
end