Add Migration in Edge not adding requested columns

I decided to just test the new feature in edge (and soon to be in Rails
2.1) where migrations are created using a UTC timestamp instead of a
number.

In a test project, where I’ve done a rake rails:freeze:edge, I did:

ruby script/generate migration AddCourse title:string

and it created a migration file: db/migrate/20080402130730_add_course.rb

but all it contains is:

class AddCourse < ActiveRecord::Migration
def self.up
end

def self.down
end
end

It doesn’t seem to want to automatically add the bits about creating the
table and adding the columns.

Am I doing something wrong? I did a quick search through the Rails Trac,
but didn’t see anything.

Thanks,

jt

John T. wrote:

I decided to just test the new feature in edge (and soon to be in Rails
2.1) where migrations are created using a UTC timestamp instead of a
number.

In a test project, where I’ve done a rake rails:freeze:edge, I did:

It doesn’t seem to want to automatically add the bits about creating the
table and adding the columns.

Am I doing something wrong? I did a quick search through the Rails Trac,
but didn’t see anything.

Well, I just tried using Rails 2.0.2 (with the latest updates) and
either I’m doing something wrong, or migrations just are broken. Doing:

ruby script/generate migration CreateCourses title:string,
coursenumber:integer, teacher:string

creates an empty migration file too. Just def up…end and def down…end

Thanks

Isn’t that syntax normally reserved for script/generate model?

Julian.

Learn Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW VIDEO
(#2) OUT NOW!
http://sensei.zenunit.com/

Julian L. wrote:

Isn’t that syntax normally reserved for script/generate model?

Julian.

Using that syntax with script/generate model or script/generate resource
does indeed create the proper file. However according to the help for
script/generate migration, it implies that it should also work:

Description:
Stubs out a new database migration. Pass the migration name, either
CamelCased or under_scored, and an optional list of attribute pairs
as argum
ents.

A migration class is generated in db/migrate prefixed by the latest 

migratio
n number.

You can name your migration in either of these formats to generate 

add/remov
e
column lines from supplied attributes: AddColumnsToTable or
RemoveColumnsFro
mTable

Example:
./script/generate migration AddSslFlag

With 4 existing migrations, this creates the AddSslFlag migration in
db/migrate/005_add_ssl_flag.rb

`./script/generate migration AddTitleBodyToPost title:string 

body:text publi
shed:boolean`

This will create the AddTitleBodyToPost in 

db/migrate/005_add_title_body_to_
post.rb with
this in the Up migration:

  add_column :posts, :title, :string
  add_column :posts, :body, :text
  add_column :posts, :published, :boolean

And this in the Down migration:

  remove_column :posts, :published
  remove_column :posts, :body
  remove_column :posts, :title

On 3 Apr 2008, at 14:31, John T. wrote:

Although it never mentions creating a table; it only discusses
AddColumnsToTable & RemoveColumnsFromTable.
If you look at the code, it’s not failing to recognise migrations like
CreateFoos, it’s just not even trying at all.

Fred

I too have run into this problem. Has anyone confirmed that this is a
defect?

On Apr 2, 4:12 pm, John T. [email protected]
wrote:

but all it contains is:
table and adding the columns.

Am I doing something wrong? I did a quick search through the Rails Trac,
but didn’t see anything.

Hello there.
What you probably wanted to do was something like

ruby script/generate migration AddCourseTo* title:string

where * means to what table ( in singular ) you’d need your column
added.

in the file produced you will find the line
add_column :*, :title, :string

where * means the name of the table ( in plural this time) where the
column is to be added

Hope that was what you needed to know.
Cheers
Allu