Trying to migrate a very simple Postgresql db to Heroku (1 table, 5
columns, 2 small migration files, no records.). The problem could be my
code for the Rake migration, it fails every time I push the code up.
This is from my logs when the app starts.
2017-10-08T01:29:53.238594+00:00 heroku[web.1]: Process exited with status 1
2017-10-08T02:30:54.224112+00:00 heroku[web.1]: State changed from crashed
to starting
2017-10-08T02:30:56.109623+00:00 heroku[web.1]: Starting process with
command `bundle exec thin start -p 56737`
2017-10-08T02:30:58.571979+00:00 app[web.1]: Using rack adapter
2017-10-08T02:30:58.571998+00:00 app[web.1]: bundler: failed to load command
: thin (/app/vendor/bundle/ruby/2.4.0/bin/thin)
2017-10-08T02:30:58.572004+00:00 app[web.1]: Sequel::Error: No database
associated with Sequel::Model: have you called Sequel.connect or Seq
uel::Model.db= ?
2017-10-08T02:30:58.572005+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0
/gems/sequel-5.1.0/lib/sequel/model/base.rb:353:in `db'
Database is working on local.
Here is the main app file (relevant doe).
require 'sinatra'
require 'slim'
require 'sass'
require 'sequel'
require './song.rb'
require 'rake'
configure :development do
password = ENV["PGPASSWORD"]
DB = Sequel.postgres('development', user: 'postgres', password: password,
host: 'localhost')
end
configure :production do
DB = Sequel.connect(ENV['DATABASE_URL'])
end
No point showing my model file, it's fine. Same with migrations, they work
and are the integer method migration(001 ...).
Rakefile:
require './main.rb'
namespace :db do
desc "Run migrations"
task :migrate, [:version] do |t, args|
require "sequel"
Sequel.extension :migration
db = Sequel.connect(ENV.fetch("DATABASE_URL"))
if args[:version]
puts "Migrating to version #{args[:version]}"
Sequel::Migrator.run(db, "migrations", target: args[:version].to_i)
else
puts "Migrating to latest"
Sequel::Migrator.run(db, "migrations")
end
end
end
Even just calling a rake on the version returns an error
vagrant@vagrant:/vagrant/TestRails/sitepoint_sinatra$ rake db:version
rake aborted!
Sequel::Error: No database associated with Sequel::Model: have you called
Sequel.connect or Sequel::Model.db= ?
/home/vagrant/.rvm/gems/ruby-2.4.1/gems/sequel-5.1.0/lib/sequel/model/base.
rb:353:in `db'
/home/vagrant/.rvm/gems/ruby-2.4.1/gems/sequel-5.1.0/lib/sequel/model/base.rb:491:in
`inherited'
The connect code is in the main file and that file is required in the model
file. As I say things work locally. Any insight would be appreciated.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.