Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Parameter "-f" for "rails generate model" does not overwrite migration files

#5526

Synopsis:
The rails g model ... -f option states, "-f, [--force] # Overwrite files that already exist" but migration file is not overwritten if it already exists for the model and results in an error message.

Using:
Rails 3.0.0
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.4.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02

Following these steps:
$ rails new demo
$ cd demo
$ rails g model testmodel
$ rails g model testmodel testfield:string -f

Receive error:
Another migration is already named create_testmodels: /Users//development/demo/db/migrate/20100901231151_create_testmodels.rb

Work around:
Delete migration file before regenerating model.

Reported by Mike Bethany · September 2nd, 2010 @ 12:25 AM

State: committed
Milestone: none
Assigned to: José Valim José Valim
Importance: none

Activity

  1. David Trasbo
    David Trasbo
    • Assigned user set to José Valim

    Here's a patch that makes rails g model and rails g migration remove the colliding migration file if you pass --force to it.

    September 2nd, 2010 @ 03:29 PM

  2. Repository