I want to reset the database of my rails 5 project, but the rails db:reset
command is not working.
errormessage:
Permission denied @ unlink_internal - C:/sites5/dawnrebirth/db/development.sqlite3
Couldn't drop database 'db/development.sqlite3'
rails aborted!
Errno::EACCES: Permission denied @ unlink_internal - C:/sites5/dawnrebirth/db/development.sqlite3
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Tasks: TOP => db:drop:_unsafe
(See full trace by running task with --trace)
db:reset: Resets your database using your migrations for the current environment. It does this by running the db:drop , db:create , db:migrate tasks. db:rollback: Rolls the schema back to the previous version, undoing the migration that you just ran. If you want to undo previous n migrations, pass STEP=n to this task.
The standard way to delete associated data in Rails is to let ActiveRecord handle it via dependent: :destroy . In the following example, when the parent model ( author ) is deleted, all data in the dependent models will get deleted by ActiveRecord as well. There is an indexed foreign key, but no foreign key constraint.
rake db:migrate - Runs the migrations which haven't been run yet. rake db:reset - Clears the database (presumably does a rake db:drop + rake db:create + rake db:migrate ) and runs migration on a fresh database.
The db:drop command drops a database using your current configuration. This command would drop a database named testDB.
Usually when rake db:reset
don't run or work for me, I just delete the development.sqlite3 and schema.rb files and re run the rake db:migrate
command to regenerate both files. But take note to Never try this in a production environment please.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With