Deleted migration.rb file? Potential bug in rails?
Asked Answered
R

3

7

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...

Rocco answered 21/10, 2011 at 12:4 Comment(2)
The same thing just happened to me. Did you figure out what happened?Leafstalk
Same thing happened to me when I ran the destroy command but attached .rb to the end of the migration name (because I'm senile). I think it is harmless but is a bug of some kind in the generator nonetheless.Nip
T
2

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.

Telefilm answered 30/11, 2012 at 18:0 Comment(1)
It also happens to me.Makings
C
1

Do you have git on your system? The same thing happened to be today and I ran:

git diff | grep migration

Nothing came out on my system. I searched for the file and still couldn't find any migration.rb on any of my Rails 3.1 projects. Probably can ignore it without any harm?

Callas answered 15/12, 2011 at 3:59 Comment(1)
I mean other Rails projects and files. Sorry.Callas
C
0

Same thing happened to me.

Looks like there is a migration.rb file within ActiveRecord, and though you can extend ActiveRecord::Base, I'm not sure you can actually access those files from somewhere within your rails project directory.

Looks like there is some precedent for deleting the migration file manually instead of through an automatic rails destroy command.

Conflagrant answered 9/1, 2013 at 1:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.