Created
July 27, 2012 17:05
-
-
Save codatory/3189186 to your computer and use it in GitHub Desktop.
This file contains 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
source :rubygems | |
gem 'mysql2' | |
gem 'sqlite3' | |
gem 'tiny_tds' | |
gem 'sequel' | |
gem 'progressbar' |
This file contains 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
require 'bundler/setup' | |
require 'mysql2' | |
require 'sqlite3' | |
require 'tiny_tds' | |
require 'sequel' | |
require 'progressbar' | |
Sequel.extension :schema_dumper, :migration, :pagination | |
db1 = Sequel.tinytds("intranet_development", :user => '', :password => '', :host => '') | |
db2 = Sequel.mysql2("intranet_development", :user => '', :password => '', :host => '', :encoding => 'utf8') | |
#migration = File.new('migrations/1_schema.rb', 'w+') | |
#migration << db1.dump_schema_migration | |
#migration.close | |
#Sequel::Migrator.apply(db2, 'migrations') | |
db2.tables.each do |tbl_name| | |
db2[tbl_name].truncate | |
next if tbl_name == :versions | |
db2.transaction do | |
p = ProgressBar.new(tbl_name, db1[tbl_name].count) | |
db1[tbl_name].each do |record| | |
db2[tbl_name].insert(record) | |
p.inc | |
end | |
p.finish | |
end | |
end | |
# gem install mysql2 -- --with-mysql-include=/usr/local/Cellar/mysql/5.5.25/include --with-mysql-lib=/usr/local/Cellar/mysql/5.5.25/lib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment