Skip to content

Instantly share code, notes, and snippets.

@mindreframer
Created July 27, 2012 12:52
Show Gist options
  • Save mindreframer/3187762 to your computer and use it in GitHub Desktop.
Save mindreframer/3187762 to your computer and use it in GitHub Desktop.
Import active_record schema without rake tasks
### sometimes your migrations don't works without already pre-populated database and your need only something to bootstrap the shell, use this script to import schema.rb without Rake-tasks and Rails!
require 'active_record'
require 'mysql2'
ROOT = File.join(File.dirname(__FILE__), '..')
DB_NAME = 'your_db_name'
['/db'].each do |folder|
$:.unshift File.join(ROOT, folder)
end
ActiveRecord::Base.configurations = {
'development' => {
'adapter' => 'mysql',
'database' => DB_NAME,
'username' => 'root',
'password' => '',
'host' => 'localhost',
'encoding' => 'utf8'
}
}
ActiveRecord::Base.establish_connection('development')
require 'db/schema'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment