Failed to run migration

i have a migration but after running it (rake db:migrate),it created a table "posts" but couldn't create columns.

class CreatePosts < ActiveRecord::Migration   def self.up     create_table :posts do |t|       t.string :name       t.string :title       t.text :content       t.timestamps      end    end     def self.down     drop_table :posts   end end

Please help!!

John

What was the output when you ran the migration? Are you sure that the table did not already exist when you ran the migration, so that it failed because it could not create the table?

If this is a new database, so there are no other tables in it then I suggest you delete the whole database, recreate the database (with no tables) and run the migration again. Note carefully what it says when you run the migration.

Colin

i have a migration but after running it (rake db:migrate),it created

a table “posts” but couldn’t create columns.

class CreatePosts < ActiveRecord::Migration

def self.up

create_table :posts do |t|

 t.string :name
 t.string :title
 t.text :content
 t.timestamps
end

end

def self.down

drop_table :posts

end

end

What was the output when you ran the migration? Are you sure that the

table did not already exist I was not sure.

when you ran the migration, so that it

failed because it could not create the table?

If this is a new database, so there are no other tables in it then I

suggest you delete the whole database, recreate the database (with no

tables) and run the migration again. Well i did exactly ,now it works .Great Colin.Thank you very

much.

Can you explain why in previous case,after running migration i

couldn’t add the

columns in table ?

John

Well i did exactly ,now it works .Great Colin.Thank you very

much.

Can you explain why in previous case,after running migration i

couldn’t add the

columns in table ?

John

i have a migration but after running it (rake db:migrate),it created

a table “posts” but couldn’t create columns.

class CreatePosts < ActiveRecord::Migration

def self.up

create_table :posts do |t|

 t.string :name
 t.string :title
 t.text :content
 t.timestamps
end

end

def self.down

drop_table :posts

end

end

What was the output when you ran the migration? Are you sure that the

table did not already exist

I was not sure.

when you ran the migration, so that it

failed because it could not create the table?

If this is a new database, so there are no other tables in it then I

suggest you delete the whole database, recreate the database (with no

tables) and run the migration again.

It is too my account.Sorry for sending from other one.

Well i did exactly ,now it works .Great Colin.Thank you very

much.

Can you explain why in previous case,after running migration i

couldn’t add the

columns in table ?

John

You can't "create" a table that already exists, you can only modify or delete it.

As I suggested before, reading the documentation on migrations -- class ActiveRecord::Migration -- would be a very good idea.

And if you're in doubt about the state of your db/tables before or after running a migration, I'd suggest you *look*. That's part of the job.