I've push my app to Heroku however my database(Sqlite3) fails to migrate. I understand that heroku will automatically migrate as a PG. [ I don't have PG install].
I figured if something was wrong, I would of received an error prompt.
This is my result:
pc-name$ heroku rake db:migrate --trace
(in /app)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
Also when I try to create-
pc-name$ heroku rake db:create --trace
cwogwtvrpc already exists
(in /app)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:create
Try destroying the app and creating it again :)
Related
I've been trying to set up a test db, but when trying to create, I keep coming across an error that I can't seem to get past when trying to populate the db.
When I execute:
bundle exec rake db:create db:migrate db:test:prepare --trace
create and migrate seem to run without errors when run separately, but test:prepare seems to throw the error.
The error starts with:
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:abort_if_pending_migrations
** Invoke environment
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:test:purge
** Execute db:test:load
** Invoke db:test:load_schema (first_time)
** Invoke db:test:purge
** Execute db:test:load_schema
** Invoke db:schema:load (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:load
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "capabilities" does not exist
LINE 5:
I've looked up, and tried a lot of the results shown on google, but none seem to help. New to this, so I'm completely stumped at this stage.
UPDATE:
I should mention that when doing:
rake db:create RAILS_ENV=test
->payments_test already exists
rake db:migrate RAILS_ENV=test
->rake aborted!
NoMethodError: undefined method `mq' for #<Rails::Application::Configuration:0x0000000508acf0> blah blah blah
Ruby rake db:seed aborting due to ** Execute db:abort_if_pending_migrations, but I think all the migrations were successful.
Here's the last portion of the output when I run rake db:migrate --trace
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump
I assume that mean it was successful (I didn't see any aborts)?
Then when I run rake db:seed --trace I get (in summary):
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
loading plugins
(the plugins load with no errors) then:
** Execute db:abort_if_pending_migrations
does this mean the migration and the seed worked properly or not?
Thank you for your time & input!
If it didn't abort, it succeeded. Take a look at the code:
# desc "Raises an error if there are pending migrations"
task :abort_if_pending_migrations => :environment do
pending_migrations = ActiveRecord::Migrator.open(ActiveRecord::Migrator.migrations_paths).pending_migrations
if pending_migrations.any?
puts "You have #{pending_migrations.size} pending #{pending_migrations.size > 1 ? 'migrations:' : 'migration:'}"
pending_migrations.each do |pending_migration|
puts ' %4d %s' % [pending_migration.version, pending_migration.name]
end
abort %{Run `rake db:migrate` to update your database then try again.}
end
end
It literally does nothing if there aren't any pending migrations.
I am running the following comand on my mac os x shell:
RAILS_ENV=test rake spec --trace
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:clone_structure (first_time)
** Invoke db:structure:dump (first_time)
** Invoke environment
** Execute db:structure:dump
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:clone_structure
** Execute spec
This command stops here for more than 5 minutes before continuing, so I don't know what is happening to cause this big big delay.
Any ideas on how can I find what is slowing down "Execute spec" ?
Thanks
I have a bootstrap task, which I intend to have db:reset and db:migrate as prerequisites. I defined it like this:
task :bootstrap => [:environment,:"db:reset",:"db:migrate"] do ...
When I run it, I get the following output:
** Invoke bs:bootstrap (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:reset (first_time)
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:drop
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config
** Execute db:create
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
-- create_table("projects", {:force=>true})
-> 0.0770s
-- create_table("users", {:force=>true})
-> 0.1110s
...
** Invoke db:seed (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment
** Execute db:abort_if_pending_migrations
You have 1 pending migrations:
20120109172252 CreateObjectives
Run "rake db:migrate" to update your database then try again.
Why isn't db:migrate being called, since it's listed as a prerequisite?
It looks like db:reset is aborting since you have pending migrations. Since db:reset will use db:schema:load to use your db/schema.rb file to reset the DB, you shouldn't really need to run migrations.
What you could do instead is put db:migrate before db:reset -- this would run migrations, update your schema.rb file so db:reset would use that updated version when resetting the DB (thus avoiding that pending migrations error).
The following is my environment:
OS X 10.5
Xcode 3.1.4
rvm 0.1.38
ruby 1.8.9-p399 (via rvm)
rails 2.3.8
I started getting this error when rake tries to run my tests:
bash$ rake
Virtual timer expired
bash$ # End of output!
And with tracing enabled:
bash$ rake --trace
** Invoke default (first_time)
** Invoke test (first_time)
** Execute test
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
Virtual timer expired
bash$
It looks like there is an problem in ruby, rev23993 causes Virtual Timer Expired when forking, which in turn triggers the error inside the mysql gem.
The practical workaround seems to be to downgrade the mysql gem from 2.8.1
to version 2.7:
#environment.rb
config.gem 'mysql', :version => '2.7'