0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Ruby on Rails】rails db:migrateができないとき...

Last updated at Posted at 2020-02-20

エラー

migrationファイル生成後、rails db:migrateとすると以下のようなエラーが出た。

$ rails db:migrate
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

試したこと

rails db:migrate:resetを実行すると...

 rails db:migrate:reset
Permission denied @ unlink_internal - C:/Users/自分/アプリ名/db/development.sqlite3
Couldn't drop database 'db/development.sqlite3'
rails aborted!
Errno::EACCES: Permission denied @ unlink_internal - C:/Users/自分/アプリ名/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)


またエラーに...

rails db:migrate:resetの代わりに、

$ rm db/development.sqlite3
$ bin/rails db:setup
を実行。

$ bin/rails db:setup
Database 'db/test.sqlite3' already exists
Run `rails db:migrate` to update your database then try again.
Created database 'db/development.sqlite3'

再度rails db:migrateにトライすると、マイグレートされました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?