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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 24 May 2011 07:25, John shelfer <johnsshelfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > endWhat 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 24, 2011 at 2:43 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 24 May 2011 07:25, John shelfer <johnsshelfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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 existI 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> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 24, 2011 at 3:08 AM, amritpal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > > On Tue, May 24, 2011 at 2:43 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 24 May 2011 07:25, John shelfer <johnsshelfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > 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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 24, 2011 at 3:35 AM, amritpal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > > On Tue, May 24, 2011 at 3:08 AM, amritpal pathak < > amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> On Tue, May 24, 2011 at 2:43 AM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>wrote: >> >>> On 24 May 2011 07:25, John shelfer <johnsshelfer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> > 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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 24, 2011 at 12:08 AM, amritpal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Can you explain why in previous case,after running migration i > couldn''t add the columns in table ?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. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.