Reputation: 11
So I made a mistake when generating the model.
I need to remove the "integer: string" and I want to the movie_id
to be a integer
not a string
. Thanks
Review(id: integer, rating: integer, comment: text, created_at: datetime, updated_at: datetime, user_id: integer, movie_id: string, integer: string)
Any help will be appreciated!
Upvotes: 1
Views: 52
Reputation: 63
You can use the command.
rake db:rollback
then go to the migration file.
remove
t.string :integer
and update
t.integer :movie_id
save and again run command.
rake db:migrate
You can also add another migration to do this. create a migration file. write following code in it
def change
remove_column :reviews, :integer, :string
change_column :reviews, :movie_id, :integer
end
and run
rake db:migragte
Upvotes: 2
Reputation: 676
You can write another migration file for that, in which you can remove the column you want and change the type of the other. In your new migration file write:
def change
remove_column :reviews, :integer, :string
change_column :reviews, :movie_id, :integer
end
Upvotes: 0