# Add Migration in Edge not adding requested columns

**URL:** <https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678>\
**Category:** Rails\
**Created:** [April 2, 2008, 3:12pm UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678 "2008-04-02T15:12:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [April 2, 2008, 3:12pm UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678/1 "2008-04-02T15:12:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [April 2, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678/2 "2008-04-02T17:34:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [April 3, 2008, 10:30am UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678/3 "2008-04-03T10:30:38Z")

</div>

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/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [April 3, 2008, 3:31pm UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678/4 "2008-04-03T15:31:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [May 30, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678/5 "2008-05-30T13:10:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [May 30, 2008, 11:47am UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678/6 "2008-05-30T11:47:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [June 27, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/add-migration-in-edge-not-adding-requested-columns/133678/7 "2008-06-27T16:10:11Z")

</div>

On Apr 2, 4:12 pm, John T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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
