| View previous topic :: View next topic |
| Author |
Message |
satya
Joined: 08 May 2008 Posts: 78
|
Posted: Mon Jul 20, 2009 12:53 pm Post subject: Does rename the model using migration in rails? |
|
|
Hi,
When I want to add one column into my existing model, I use command like this:
script/generate migration AddPermalinkToPost permalink:string
It will generate a migration file.
is there any command to rename the existing model using migrations?
Thanks in advance. |
|
| Back to top |
|
 |
sharma I
Joined: 13 Jun 2008 Posts: 130
|
Posted: Mon Jul 20, 2009 1:02 pm Post subject: |
|
|
Hi Satya,
From your rails root , create a migration by using the following command
ruby script/generate migration RenamePostToForum
It creates a migration file in your db/migrate folder and add the following code to the existing file.
def up
rename_table :posts, :forums
end
def down
rename_table :forums, :posts
end
I hope this can helps you.
Thank You. |
|
| Back to top |
|
 |
|