Created
July 27, 2012 12:52
-
-
Save mindreframer/3187762 to your computer and use it in GitHub Desktop.
Import active_record schema without rake tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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