Trying to run db:migrate
keep getting rake aborted
== CreateLocalKeys: migrating ================================================
rake aborted!
An error has occurred, all later migrations canceled:
Permission denied - rsa_key
I can't find anything about this
any help is appreciated
Thanks
Are you trying to install Insoshi? If so, I would assume the user account running the migration does not have write access to the local filesystem. The particular migration writes keys to a local file as seen here: http://github.com/insoshi/insoshi/blob/master/db/migrate/012_create_local_keys.rb
I'm assuming your user account needs write access in your rails root directory (at a minimum). Probably a little chown/chmod love will help.
sudo rake db:migrate
First thing I can think of. But I've never had a problem running db:migrate.
Related
I am trying to reset my development Database for my Rails 5.0 project on Windows, but when I run (same as rake db:drop)
rails db:drop
I get the following error:
Errno::EACCES Permission denied # unlink_internal
I restarted my PC already to make sure that rails was not running in anyway
You just need to exit the Rails Server.
I had the same error trying to reset my sqlite3 db on Windows, using rails 5.1.6 while doing the Learn Enough to Be Dangerous Rails tutorial. I found the following answer on another post, and it worked for me:
"For Dropping entire database just give rake db:setup it drops and again creates the database for you."
When I run the command, I get:
$ rails db:setup
Database 'db/development.sqlite3' already exists
Database 'db/test.sqlite3' already exists
-- create_table("users", {:force=>:cascade})
-> 0.0497s
-- create_table("users", {:force=>:cascade})
-> 0.0624s
And my database seems to work as expected, but with no data.
This can help
When I need to remove data base then I use rake db:reset.
Please try it.
Hope it helps.
Found Solution:
In windows machine you would have to specify that it is an unsafe move, so i
rake db:drop_unsafe
rails db:migrate
this is for windows machine, if you're using Linux then you can do just
rake db:reset
I'm trying to deploy my Rails app to Heroku, and I now want to load my schema. I get the following error:
Running `bundle exec rake db:schema:load` attached to terminal... up, run.1533
rake aborted!
PG::ConnectionBad: FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
Which is weird because postgres is not the database it should connect to. The database URL, which is available to the app via ENV, has the right values, and the long apparently random name d3kwlkwlwjwljetc....
Searching for this message gives me people who are trying to drop or reset the DB, which is not what I'm doing.
I have 0 rows
I tried pg:reset, even removed and put back the database. No avail.
I'm not doing db:drop, just db:schema:load
I'm dumbfounded. Why can't my app connect?
Edit: Apparently, I can't schema:load, but I can migrate all my migrations over. Why is that?
It appears that this is an issue in Rails itself - there is a discussion regarding it at https://github.com/rails/rails/issues/17945 - it seems that there's a commit (https://github.com/rails/rails/blob/master/activerecord/lib/active_record/tasks/postgresql_database_tasks.rb#L77) that is connecting to the posgres database which isn't permitted on Heroku so fails.
In short, for the moment use db:migrate until the issue is resolved.
I am learning Ruby on Rails, an am getting an error creating the database. I run the following command from console:
rake db:create db:migrate db:seed
And get:
== 20140328232600 AddAuthLevelToUser: migrating ===============================
-- add_column(:users, :auth_level, :Integer)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "users" does not exist
I looked at the error message on the webpage, and tried running:
'bin/rake db:migrate RAILS_ENV=development'
As suggested, but had little luck.
The project I am working on had been started by another team of developers, so I pulled it off git... Any suggestions?
Cheers
As per the error, you are running the migration AddAuthLevelToUser when you don't even have users table in database.
Firstly, verify if you have migration for users table, if not then create one.
If yes, then check that migration for users table has a VERSION NUMBER lower than that of AddAuthLevelToUser. Fix it and run the migrations.
Try running just rake db:create at first. What database is your project using? Work this out and use the database client to connect to the database on your local system, and verify whether the users table exists on the database. It's possible that the db:create job is not correctly creating all the tables necessary for the database schema.
I am having a lot of issues with rails migration mechanism.
I think I have run a migration file and has been executed partially.
So when I am trying to run
rake db:migrate
again it gives me an error the column name already exist.
I am trying to reset it with
rake db:reset
and gives me an error
Unknown database 'databasename'
Is there a way to reset the whole mechanism ?
Is it a good idea to manually drop all tables and try to run rake db:migrate again ?
You should change the database name in your database.yml.
I am following the rails tutorial videos and I can't figure out what the db:test:prepare command actually does. Can someone provide an explanation?
The rake db:migrate above runs any pending migrations on the
development environment and updates db/schema.rb. The rake
db:test:load recreates the test database from the current
db/schema.rb. On subsequent attempts, it is a good idea to first run
db:test:prepare, as it first checks for pending migrations and warns
you appropriately.
-- http://guides.rubyonrails.org/testing.html
Basically it handles cloning the database so you don't have to run the migrations against test to update the test database.
Specifically, rake db:test:prepare will do the following:
Check for pending migrations and,
load the test schema
That is, it will look your db/schema.rb file to determine if any migrations that exist in your project that have not been run. Assuming there are no outstanding migrations, it will then empty the database and reload it based on the contents of the db/schema.rb file.
rake db:test:prepare is a good solution for PG issues like this.
“PG::UndefinedTable: ERROR: relation does not exist” with a correct Rails naming and convention" where I couldn't just execute rake db:migrate RAILS_ENV=production
When, for example you can't create test database for a bug discussed here: "PG undefinedtable error relation users does not exist"
All arround this error
"PG::UndefinedTable: ERROR: relation xxxxx does not exist”