I cloned a repo from bitbucket now trying to set it up on localhost machine.
SQLite3::SQLException: no such table: test_123: ALTER TABLE "test_123" ADD "icon_file_name"
rake db:drop
rake db:create
rake db:migrate
But still getting that same issue. What is solution for this?
Related
this is what I get when I run the project
Hi, I'm working on a project.
When I run my project, I got this problem:
Migrations are pending. To resolve this issue, run:
bin/rake db:migrate RAILS_ENV=development
raise ActiveRecord::PendingMigrationError if ActiveRecord::Migrator.needs_migration?
(connection)
I've already tried several solutions below:
1)
rake db:drop
rake db:create
rake db:migrate
2) bundle exec rake db:migrate
3) bin/rake db:migrate RAILS_ENV=development
but they didn't work, and I got the same error over and over again.
What can I do?
Your first try was close, you need to do
rake db:drop
rake db:create
rake db:schema:load
Check this article it may be helpful.
http://icebergist.com/posts/rake-db-migrate-vs-rake-db-schema-load/
$ rm db/schema.rb
$ bundle exec rake db:drop
$ bundle exec rake db:create
$ bundle exec rake db:migrate
Or just rake db:reset. That always works for me, when I get stuck.
I'm typing in the terminal
rake db:migrate
Here's the error Im getting
ActiveRecord::NoDatabaseError: FATAL: database "db/development.sqlite3" does not exist
rake db:migrate doesn't create database, rather requires it exists.
rake db:create creates a database without loading database schema.
Remember you should run rake db:create before you can run rake db:migrate if you dropped database with rake db:drop.
When I try to load a page of my site, I get:
ActiveRecord::PendingMigrationError Migrations are pending.
To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
But when I when I run rake db:migrate I get:
SQLite3::SQLException table "options" already exists...
Running rake db:reset doesn't fix anything either. Trying to load a page still gives me the PendingMigrationError.
If instead I run rake db: drop and then rake db:migrate, I get this:
rake aborted
Standard Error! An error has occured, this and all later migrations canceled.
undefined method 'can_pick_many_options' ....
Note: I'm running Rails 4.1.2
I appear to have a circular issue in regards to Ruby on Rails migration procedure. I am following the introduction article and I have reached the point when I need to create my first table.
I have ran the following,
[tims#web2 working_ror]# rails generate model Homepage first_name:string last_name:string email:string message:text
invoke active_record
create db/migrate/20131119203948_create_homepages.rb
create app/models/homepage.rb
invoke test_unit
createtest /models/homepage_test.rb
createtest /fixtures/homepages.yml
I then proceeded with the migration,
[tims#web2 working_ror]# rake db:migrate
== CreateHomepages: migrating ================================================
-- create_table(:homepages)
-> 0.0493s
== CreateHomepages: migrated (0.0494s) =======================================
, however, when I run my application I see the following message,
Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue.
but, IF I run the above,
[tims#web2 working_ror]# rake db:migrate RAILS_ENV=development
[tims#web2 working_ror]#
and the message continues ...
I have spent considerable amount of time researching forums in-which the closest I could find was to drop and re-build everything, which have done the following.
rake db:drop
rake db:create
rake db:migrate
and the results are the same.
You need to do
bundle exec rake test:prepare
or
bundle exec rake db:test:prepare
and then
bundle exec rake db:migrate
before running the specs
Cheers
cited from : Why am I asked to run 'rake db:migrate RAILS_ENV=test'?
you can do
bundle exec rake test:prepare
In Rails 4.1+, they deprecated db:test:prepare
You can now just use:
ActiveRecord::Migration.maintain_test_schema!
If you need to do it manually
rake db:schema:load RAILS_ENV=test
and then
bundle exec rake db:migrate
try
In RAILS_ROOT/config/environments/development.rb Set the following setting to false:
config.active_record.migration_error = false#:page_load
One weird trick that you can use when your migrations are screwed (file deleted, manually renamed, etc.)
Fire up your favourite DB admin tool (eg. PGAdmin3) and browse to the database in question.
Look for a table called schema_migrations and browse its content. It should have a single column called version. This field is used by Rails to check whether migrations are up to date.
Make sure that your migration timestamps corresponds with the data in this column. If you have deleted an older migration, delete the corresponding timestamp.
Check to make sure that table doesn't already exist:
type - rails dbconsole
type - .tables (check to see if there was an error during the rake db:migrate that has the table name like -- create_table(:test) rake aborted!)
If you see the table name after running the .tables in the console type - drop table TABLENAME;
Then .quit to go back to the branch and run the rake db:migrate command again.
this was what i did:
rails db:environment:set RAILS_ENV=test
If you need to do it manually
rake db:schema:load RAILS_ENV=test
and then
bundle exec rake db:migrate
Thanks to Ahmed Ali....... your comment was helpful.
Utterly confused at this mess:
rake db:drop
>
rake db:create
> my_database already exists
rake db:migrate
> unknown database my_database
Appreciate any insight.
That's because first time when u do rake db:create it creates two databases one is development and other is test. then when u do rake db:drop it drops the database, but it only drops the development database not the test database. so try removing the test database explicitly and everything should be fine.
Try :
rake db:drop
rake db:create RAILS_ENV=development
rake db:migrate RAILS_ENV=development
if getting same error then open mysql terminal and create database manually :
CREATE DATABASE database_name;
then run
rake db:migrate