railsのマイグレーションステータス'NO FILE'を削除する
code:sh
❯ rails db:migrate:status
database: db/development.sqlite3
Status Migration ID Migration Name
--------------------------------------------------
up 20201121230730 Create books
up 20201121231228 Add author to books
up 20201121231845 Add picture to books
up 20201122003800 Devise create users
up 20201122011641 Add name and postal code and address and self introduction to users
up 20201122065204 Add omniauth to users
up 20201122075737 Create active storage tablesactive storage
up 20201227052520 Add service name to active storage blobsactive storage
up 20201227052521 Create active storage variant recordsactive storage
up 20210531231050 Remove omniauth columns from users
up 20220410150944 ********** NO FILE **********
down 20220418040546 Create follow relations
~/fBootcamp/fjord-books_app my-follow_users*
❯ rails db:rollback
^[[A^[[Arails aborted!
ActiveRecord::UnknownMigrationVersionError:
No migration with version number 20220410150944.
/Users/usagi/fBootcamp/fjord-books_app/bin/rails:5:in `<top (required)>'
/Users/usagi/fBootcamp/fjord-books_app/bin/spring:8:in `block in <top (required)>'
/Users/usagi/fBootcamp/fjord-books_app/bin/spring:5:in `<top (required)>'
Tasks: TOP => db:rollback
(See full trace by running task with --trace)
~/fBootcamp/fjord-books_app my-follow_users*
❯ $ vim db/migrate/20220410150944_tmp.rb
zsh: command not found: $
~/fBootcamp/fjord-books_app my-follow_users*
❯ vim db/migrate/20220410150944_tmp.rb
~/fBootcamp/fjord-books_app my-follow_users* 27s
❯ rails db:migrate:status
database: db/development.sqlite3
Status Migration ID Migration Name
--------------------------------------------------
up 20201121230730 Create books
up 20201121231228 Add author to books
up 20201121231845 Add picture to books
up 20201122003800 Devise create users
up 20201122011641 Add name and postal code and address and self introduction to users
up 20201122065204 Add omniauth to users
up 20201122075737 Create active storage tablesactive storage
up 20201227052520 Add service name to active storage blobsactive storage
up 20201227052521 Create active storage variant recordsactive storage
up 20210531231050 Remove omniauth columns from users
up 20220410150944 Tmp
down 20220418040546 Create follow relations
~/fBootcamp/fjord-books_app my-follow_users*
❯ bundle exec rake db:migrate:down VERSION=20220410150944
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class Tmp < ActiveRecord::Migration4.2 /Users/usagi/fBootcamp/fjord-books_app/db/migrate/20220410150944_tmp.rb:1:in `<main>'
/Users/usagi/.rbenv/versions/3.0.1/bin/bundle:23:in `load'
/Users/usagi/.rbenv/versions/3.0.1/bin/bundle:23:in `<main>'
Caused by:
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class Tmp < ActiveRecord::Migration4.2 /Users/usagi/fBootcamp/fjord-books_app/db/migrate/20220410150944_tmp.rb:1:in `<main>'
/Users/usagi/.rbenv/versions/3.0.1/bin/bundle:23:in `load'
/Users/usagi/.rbenv/versions/3.0.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate:down
(See full trace by running task with --trace)
~/fBootcamp/fjord-books_app my-follow_users*
❯ rails db:rollback
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class Tmp < ActiveRecord::Migration4.2 /Users/usagi/fBootcamp/fjord-books_app/db/migrate/20220410150944_tmp.rb:1:in `<main>'
/Users/usagi/fBootcamp/fjord-books_app/bin/rails:5:in `<top (required)>'
/Users/usagi/fBootcamp/fjord-books_app/bin/spring:8:in `block in <top (required)>'
/Users/usagi/fBootcamp/fjord-books_app/bin/spring:5:in `<top (required)>'
Caused by:
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class Tmp < ActiveRecord::Migration4.2 /Users/usagi/fBootcamp/fjord-books_app/db/migrate/20220410150944_tmp.rb:1:in `<main>'
/Users/usagi/fBootcamp/fjord-books_app/bin/rails:5:in `<top (required)>'
/Users/usagi/fBootcamp/fjord-books_app/bin/spring:8:in `block in <top (required)>'
/Users/usagi/fBootcamp/fjord-books_app/bin/spring:5:in `<top (required)>'
Tasks: TOP => db:rollback
(See full trace by running task with --trace)
~/fBootcamp/fjord-books_app my-follow_users*
❯ bundle exec rake db:migrate:down VERSION=20220410150944
== 20220410150944 Tmp: reverting ==============================================
== 20220410150944 Tmp: reverted (0.0066s) =====================================
~/fBootcamp/fjord-books_app my-follow_users*
❯ rails db:migrate:status
database: db/development.sqlite3
Status Migration ID Migration Name
--------------------------------------------------
up 20201121230730 Create books
up 20201121231228 Add author to books
up 20201121231845 Add picture to books
up 20201122003800 Devise create users
up 20201122011641 Add name and postal code and address and self introduction to users
up 20201122065204 Add omniauth to users
up 20201122075737 Create active storage tablesactive storage
up 20201227052520 Add service name to active storage blobsactive storage
up 20201227052521 Create active storage variant recordsactive storage
up 20210531231050 Remove omniauth columns from users
down 20220410150944 Tmp
down 20220418040546 Create follow relations
~/fBootcamp/fjord-books_app my-follow_users*
❯ rm -rf db/migrate/20220410150944_tmp.rb
~/fBootcamp/fjord-books_app my-follow_users*
❯ rails db:migrate:status
database: db/development.sqlite3
Status Migration ID Migration Name
--------------------------------------------------
up 20201121230730 Create books
up 20201121231228 Add author to books
up 20201121231845 Add picture to books
up 20201122003800 Devise create users
up 20201122011641 Add name and postal code and address and self introduction to users
up 20201122065204 Add omniauth to users
up 20201122075737 Create active storage tablesactive storage
up 20201227052520 Add service name to active storage blobsactive storage
up 20201227052521 Create active storage variant recordsactive storage
up 20210531231050 Remove omniauth columns from users
down 20220418040546 Create follow relations
~/fBootcamp/fjord-books_app my-follow_users*
❯ rails db:migrate
== 20220418040546 CreateFollowRelations: migrating ============================
-- create_table(:follow_relations)
-> 0.0026s
-- add_index(:follow_relations, :follower_id)
-> 0.0011s
-- add_index(:follow_relations, :followed_id)
-> 0.0010s
-> 0.0011s
== 20220418040546 CreateFollowRelations: migrated (0.0065s) ===================
~/fBootcamp/fjord-books_app my-follow_users*
❯ rails db:migrate:status
database: db/development.sqlite3
Status Migration ID Migration Name
--------------------------------------------------
up 20201121230730 Create books
up 20201121231228 Add author to books
up 20201121231845 Add picture to books
up 20201122003800 Devise create users
up 20201122011641 Add name and postal code and address and self introduction to users
up 20201122065204 Add omniauth to users
up 20201122075737 Create active storage tablesactive storage
up 20201227052520 Add service name to active storage blobsactive storage
up 20201227052521 Create active storage variant recordsactive storage
up 20210531231050 Remove omniauth columns from users
up 20220418040546 Create follow relations
~/fBootcamp/fjord-books_app my-follow_users*
❯