class PostDB::CLI::Database
Public Instance Methods
configuration()
click to toggle source
Get the database configuration
Example:
>> configuration => { adapter: "mysql", host: "127.0.0.1", username: "mail", password: "...", database: "mail" }
# File lib/postdb/cli/database.rb, line 23 def configuration PostDB::Configuration[:database] end
connection()
click to toggle source
Get the ActiveRecord::Base connection
Example:
>> connection => ?
# File lib/postdb/cli/database.rb, line 13 def connection ActiveRecord::Base.connection end
migrate(version = nil)
click to toggle source
# File lib/postdb/cli/database.rb, line 29 def migrate(version = nil) # Get the path to the migrations directory migrations = File.join('..', '..', '..', '..', 'db', 'migrate') migrations = File.expand_path(migrations, __FILE__) # Run the migrations ActiveRecord::Migrator.migrate(migrations, version) end