Reputation: 93
I'm trying to migrate a small SQLite database to PostgreSQL so that I can put it on Heroku. The plan is to migrate the local database to a instance of PostgreSQL. Once I know that works fine I'll migrate the database to heroku.
It is proving to be extremely difficult. I'm not use to Ruby on Rails, so probably missing all the tricks.
I'm running Ruby 2.2.0 / Rails 4.2.0 on MAC
Any thoughs on what the issue is/
I'm running the following command to migrate from SQLite3 to PostgreSQL. Note the Db:migrate worked and the database schema is in place. I just need to get the data into it now.
taps pull postgres://user@localhost/db/development http://user:secret@localhost:5000
I then get the following output:
Receiving schema Unable to fetch tables information from http://user:secret@localhost:5000. Please check the server log.
In another terminal where I started the service I get the following which contains an error referring to a table:
Rack::Utils::OkJson::Error - cannot encode Symbol: :schema_migrations::
$ **taps server sqlite://db/development.sqlite3 USER secret**
== Sinatra/1.0 has taken the stage on 5000 for production with backup from WEBrick
[2015-05-06 17:28:09] INFO WEBrick 1.3.1
[2015-05-06 17:28:09] INFO ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
[2015-05-06 17:28:09] INFO WEBrick::HTTPServer#start: pid=8274 port=5000
127.0.0.1 - USER [06/May/2015:17:28:57 +0100] "GET / HTTP/1.1" 200 - 0.0010
localhost - - [06/May/2015:17:28:57 BST] "GET / HTTP/1.1" 200 31
- -> /
127.0.0.1 - USER [06/May/2015:17:28:57 +0100] "POST /sessions HTTP/1.1" 200 - 0.0158
localhost - - [06/May/2015:17:28:57 BST] "POST /sessions HTTP/1.1" 200 46
- -> /sessions
Rack::Utils::OkJson::Error - cannot encode Symbol: :schema_migrations:
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/utils/okjson.rb:427:in `valenc'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/utils/okjson.rb:438:in `block in arrenc'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/utils/okjson.rb:438:in `map'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/utils/okjson.rb:438:in `arrenc'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/utils/okjson.rb:410:in `encode'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/taps-0.3.24/lib/taps/server.rb:157:in `block in <class:Server>'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:865:in `call'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:865:in `block in route'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `instance_eval'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `route_eval'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:500:in `block (2 levels) in route!'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `catch'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `block in route!'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `each'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:476:in `route!'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:601:in `dispatch!'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `block in call!'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `instance_eval'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `block in invoke'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `catch'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:566:in `invoke'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:411:in `call!'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:399:in `call'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/deflater.rb:35:in `call'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/auth/basic.rb:25:in `call'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/commonlogger.rb:33:in `call'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `block in call'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:1005:in `synchronize'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:979:in `call'
/Users/USER/.rvm/gems/ruby-2.2.0/gems/rack-1.6.0/lib/rack/handler/webrick.rb:89:in `service'
/Users/USER/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/USER/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/USER/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
ERROR: Rack::Utils::OkJson::Error: cannot encode Symbol: :schema_migrations
[2015-05-06 17:28:57] ERROR NoMethodError: undefined method `blank?' for {}:Hash
...........
localhost - - [06/May/2015:17:28:57 BST] "GET /sessions/1568289369/pull/table_names HTTP/1.1" 500 317 - -> /sessions/1568289369/pull/table_names
Upvotes: 0
Views: 701
Reputation: 72
dont use taps, use sequel command like:
sequel -C sqlite://db/development.sqlite3 postgres://pgusername:pguserpassword@localhost/development_db
just for google = )
Upvotes: 1
Reputation: 78
Make sure to use the correct version of ruby in this case 2.0.0, I would recommend installing and using RVM if you have not done so already.
RVM use 2.0.0
Have two terminal windows open ensuring both are pointing to ruby 2.0.0 as opening a new terminal will revert to your default version of ruby, check by
ruby -v
change your gemfile to:
gem 'rack','1.0.1'
gem 'sqlite3'
gem 'pg'
gem 'taps'
and run
bundle
on one terminal within your project run the sqlite server:
taps server sqlite://db/development.sqlite3 user password
on the second terminal within your project run:
taps pull postgres://user@localhost/db/development http://user:secret@localhost:5000
This should do it.
Then replace your gem file and use the version of ruby you want!
Upvotes: 0