-1

I have a problem with my migration. It returns me that:

database: THP_POS_development

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     000             ********** NO FILE **********
   up     20191202102702  Devise create users

Please help me ;) I just want to delete the migration no file with the migration 000, because I work in an app project and I can push my works on gitHub if I have this problem. This migration is going to be pushed

sarra
  • 1
  • 1

2 Answers2

2

If this is on your development machine only, there are a few options:

1) Drop the database and recreate it, using the present migrations. Take the following steps

rake db:drop 
rake db:create 
rake db:migrate 

This will recreate the database using only the present migrations, like a clean start, and since the 000 migration file is gone, it will not be recreated.

2) rollback all the migrations, from your list only two, and then run the migrations again

 rake db:rollback STEP=2
 rake db:migrate 

this does nearly the same as the previous option, I guess it depends on how migrations you need to rollback to see which is the easiest.

These will only work if the migration with version '000' is NOT already deployed, or migrated by your fellow developers (when working in a team). If that is the case, I would consider the following options:

  • squash all migrations into one (e.g. load the schema file from a migration)
  • create a new migration-file with the missing-number and ... restore what it contained before (even if it was empty?)
nathanvda
  • 49,707
  • 13
  • 117
  • 139
0

As described in this answer, a short solution would be to delete the missing migration from the schema_migration list so that rails doesn't fail looking for a file that doesn't exist.

  1. Enter into your dbconsole
rails dbconsole
  1. Delete the migration (here the id would be 000)
delete from schema_migrations where version='<MIGRATION_ID>';