Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleted migration.rb file? Potential bug in rails?

I am not sure if this is a bug or if this actually removed a migration.rb file. I used generate to create the following migration:

$ rails generate migration add_delta_to_submissions

    invoke  active_record  
    create    db/migrate/20111020175649_add_delta_to_submissions.rb  

I then realized that I neglected to include any columns, so I used the UP ARROW in the console and overwrote generate with destroy:

$ rails destroy migration add_delta_to_submissions

    invoke  active_record  
    remove    db/migrate/20111020175649_add_delta_to_submissions.rb  

All good so far, now its time to run the migration with the column I need. Here is where the problem comes in - I used the UP ARROW again - but only once - and added my column info:

$ rails destroy migration add_delta_to_submissions delta:integer

    invoke  active_record  
    remove    migration.rb  

I realize I should probably NOT be using the UP ARROW for commands as volatile as GENERATE and DESTROY (lesson learned!), but that command came back stating it REMOVED the migration.rb file. I didn't even know there was a migration.rb file - especially not one that could be removed so easily.

For kicks, I decided to try and trick the command console by adding the letter x to the end of word migration - and received this message:

$ rails destroy migrationx add_delta_to_submissions delta:integer

    Could not find generator migrationx.  

So, I think there could be a bug with the rails destroy command. Once it realized there was no longer a add_delta_to_submissions.rb file, it just lopped that off and tacked on the .rb to the word migration (or any word after DESTROY). That seems a bit dangerous....

Regardless of that - I am curious to know if I have somehow compromised my RAILS environment (rails 3.1, ruby 1.8.7) now that the migration.rb file has been removed. If so - what are my options for fixing that situation?

Many thanks in advance...

like image 964
user1006982 Avatar asked Oct 21 '11 12:10

user1006982


1 Answers

It also happens when you type a non-existing migration name as parameter to destroy command

$rails migration destroy non-existing-migration-name 

invoke    active_record
remove    migration.rb

But I think it is harmless.

like image 138
Erdem Gezer Avatar answered Sep 23 '22 07:09

Erdem Gezer