I''m having a silly little problem with migrations. All I''m trying to do is to add an SSN column to my Employees table. I generated a migration which looks like: class AddSsn < ActiveRecord::Migration def self.up add_column :employees, :ssn, :string end def self.down remove_column :employees, :ssn end end When I run this, however, I get: >rake db:migrate (in C:/workspace/hr) rake aborted! uninitialized constant Ssn I tried running with --trace but I don''t see how that helped. I did have the migration syntax wrong a couple of times, but now even though I think it''s fine, it still doesn''t work. Any suggestions would be appreciated. I''m running Ruby 1.8.4 with Rails 1.1.2 on Windows, btw. Ken Kousen -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen-PxcIC9p/5bhWk0Htik3J/w@public.gmane.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I fixed it by changing the name of the migration from 002_ssn.rb to 002_add_ssn.rb. I have no idea why that worked, but it did the trick. Ken Kousen -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen-PxcIC9p/5bhWk0Htik3J/w@public.gmane.org -------- Original Message -------- Subject: [Rails] rake aborted when adding a column From: Ken Kousen Date: Tue, May 16, 2006 1:23 pm To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org I''m having a silly little problem with migrations. All I''m trying to do is to add an SSN column to my Employees table. I generated a migration which looks like: class AddSsn < ActiveRecord::Migration def self.up add_column :employees, :ssn, :string end def self.down remove_column :employees, :ssn end end When I run this, however, I get: >rake db:migrate (in C:/workspace/hr) rake aborted! uninitialized constant Ssn I tried running with --trace but I don''t see how that helped. I did have the migration syntax wrong a couple of times, but now even though I think it''s fine, it still doesn''t work. Any suggestions would be appreciated. I''m running Ruby 1.8.4 with Rails 1.1.2 on Windows, btw. Ken Kousen -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen-PxcIC9p/5bhWk0Htik3J/w@public.gmane.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Ken Kousen, It is called name convention in rails. If your class is CreateVendors, your migration file should be xxx_create_vendors.rb ... ________________________________ From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Ken Kousen Sent: Tuesday, May 16, 2006 2:04 PM To: rails@lists.rubyonrails.org Subject: RE: [Rails] rake aborted when adding a column I fixed it by changing the name of the migration from 002_ssn.rb to 002_add_ssn.rb. I have no idea why that worked, but it did the trick. Ken Kousen -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com <http://www.kousenit.com/> ken.kousen@kousenit.com -------- Original Message -------- Subject: [Rails] rake aborted when adding a column From: Ken Kousen <ken.kousen@kousenit.com> Date: Tue, May 16, 2006 1:23 pm To: rails@lists.rubyonrails.org I''m having a silly little problem with migrations. All I''m trying to do is to add an SSN column to my Employees table. I generated a migration which looks like: class AddSsn < ActiveRecord::Migration def self.up add_column :employees, :ssn, :string end def self.down remove_column :employees, :ssn end end When I run this, however, I get: >rake db:migrate (in C:/workspace/hr) rake aborted! uninitialized constant Ssn I tried running with --trace but I don''t see how that helped. I did have the migration syntax wrong a couple of times, but now even though I think it''s fine, it still doesn''t work. Any suggestions would be appreciated. I''m running Ruby 1.8.4 with Rails 1.1.2 on Windows, btw. Ken Kousen -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com <http://www.kousenit.com/> ken.kousen@kousenit.com ________________________________ _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060516/552fddcb/attachment.html
I haven''t had a problem using semi-arbitrary naming for my migrations. Examples include xxx_add_yyy, xxx_create_yyy, xxx_change_yyy, xxx_make_yyy. And the yyy in my examples is frequently NOT just the table name, so I am pretty sure that whatever naming conventions exist for migrations they are not strictly enforced by rake. On 5/16/06, Socheat Yi <syi@simworld.com> wrote:> > Hi Ken Kousen, > > > > It is called name convention in rails. If your class is CreateVendors, > your migration file should be xxx_create_vendors.rb ? > > > > > > > ------------------------------ > > *From:* rails-bounces@lists.rubyonrails.org [mailto: > rails-bounces@lists.rubyonrails.org] *On Behalf Of *Ken Kousen > *Sent:* Tuesday, May 16, 2006 2:04 PM > > *To:* rails@lists.rubyonrails.org > *Subject:* RE: [Rails] rake aborted when adding a column > > > > I fixed it by changing the name of the migration from 002_ssn.rb to > 002_add_ssn.rb. I have no idea why that worked, but it did the trick. > > > > Ken Kousen > > -- > Kenneth A. Kousen, Ph.D. > President > Kousen IT, Inc. > http://www.kousenit.com > ken.kousen@kousenit.com > > > > -------- Original Message -------- > Subject: [Rails] rake aborted when adding a column > From: Ken Kousen <ken.kousen@kousenit.com> > Date: Tue, May 16, 2006 1:23 pm > To: rails@lists.rubyonrails.org > > I''m having a silly little problem with migrations. All I''m trying to do > is to add an SSN column to my Employees table. I generated a migration > which looks like: > > > > *class* AddSsn < ActiveRecord::Migration > > * def* self.up > > add_column *:employees*, *:ssn*, *:string* > > * end* > > * def* self.down > > remove_column *:employees*, *:ssn* > > * end* > > *end* > > > When I run this, however, I get: > > >rake db:migrate > > (in C:/workspace/hr) > > rake aborted! > > uninitialized constant Ssn > > > > I tried running with --trace but I don''t see how that helped. I did have > the migration syntax wrong a couple of times, but now even though I think > it''s fine, it still doesn''t work. > > > > Any suggestions would be appreciated. > > > > I''m running Ruby 1.8.4 with Rails 1.1.2 on Windows, btw. > > > > Ken Kousen > -- > Kenneth A. Kousen, Ph.D. > President > Kousen IT, Inc. > http://www.kousenit.com > ken.kousen@kousenit.com > ------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060516/711874f8/attachment-0001.html
I was going to say that I''m not adding a class at all. This is just adding a column to an existing table. Then I realized that the migration itself is a class, of course, so I need to follow the naming convention. I get it now. Thanks, Ken -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen-PxcIC9p/5bhWk0Htik3J/w@public.gmane.org -------- Original Message -------- Subject: RE: [Rails] rake aborted when adding a column From: "Socheat Yi" Date: Tue, May 16, 2006 2:08 pm To: Hi Ken Kousen, It is called name convention in rails. If your class is CreateVendors, your migration file should be xxx_create_vendors.rb … From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ken Kousen Sent: Tuesday, May 16, 2006 2:04 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails] rake aborted when adding a column I fixed it by changing the name of the migration from 002_ssn.rb to 002_add_ssn.rb. I have no idea why that worked, but it did the trick. Ken Kousen -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen-PxcIC9p/5bhWk0Htik3J/w@public.gmane.org -------- Original Message -------- Subject: [Rails] rake aborted when adding a column From: Ken Kousen Date: Tue, May 16, 2006 1:23 pm To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org I''m having a silly little problem with migrations. All I''m trying to do is to add an SSN column to my Employees table. I generated a migration which looks like: class AddSsn < ActiveRecord::Migration def self.up add_column :employees, :ssn, :string end def self.down remove_column :employees, :ssn end end When I run this, however, I get: >rake db:migrate (in C:/workspace/hr) rake aborted! uninitialized constant Ssn I tried running with --trace but I don''t see how that helped. I did have the migration syntax wrong a couple of times, but now even though I think it''s fine, it still doesn''t work. Any suggestions would be appreciated. I''m running Ruby 1.8.4 with Rails 1.1.2 on Windows, btw. Ken Kousen -- Kenneth A. Kousen, Ph.D. President Kousen IT, Inc. http://www.kousenit.com ken.kousen-PxcIC9p/5bhWk0Htik3J/w@public.gmane.org _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Whoops, missed the nuance of what you were saying. Yes, the file name and migration class name must be the same. But the name for the migration doesn''t have to match what you are doing (e.g. 002_add_vendors_column). On 5/16/06, Eden Brandeis <ebrandeis@gmail.com> wrote:> > I haven''t had a problem using semi-arbitrary naming for my migrations. > Examples include xxx_add_yyy, xxx_create_yyy, xxx_change_yyy, xxx_make_yyy. > And the yyy in my examples is frequently NOT just the table name, so I am > pretty sure that whatever naming conventions exist for migrations they are > not strictly enforced by rake. > > > On 5/16/06, Socheat Yi <syi@simworld.com> wrote: > > > > Hi Ken Kousen, > > > > > > > > It is called name convention in rails. If your class is CreateVendors, > > your migration file should be xxx_create_vendors.rb ? > > > > > > > > > > > > > > ------------------------------ > > > > *From:* rails-bounces@lists.rubyonrails.org [mailto: > > rails-bounces@lists.rubyonrails.org] *On Behalf Of *Ken Kousen > > *Sent:* Tuesday, May 16, 2006 2:04 PM > > > > *To:* rails@lists.rubyonrails.org > > *Subject:* RE: [Rails] rake aborted when adding a column > > > > > > > > I fixed it by changing the name of the migration from 002_ssn.rb to > > 002_add_ssn.rb. I have no idea why that worked, but it did the trick. > > > > > > > > Ken Kousen > > > > -- > > Kenneth A. Kousen, Ph.D. > > President > > Kousen IT, Inc. > > http://www.kousenit.com > > ken.kousen@kousenit.com > > > > > > > > -------- Original Message -------- > > Subject: [Rails] rake aborted when adding a column > > From: Ken Kousen <ken.kousen@kousenit.com> > > Date: Tue, May 16, 2006 1:23 pm > > To: rails@lists.rubyonrails.org > > > > I''m having a silly little problem with migrations. All I''m trying to do > > is to add an SSN column to my Employees table. I generated a migration > > which looks like: > > > > > > > > *class* AddSsn < ActiveRecord::Migration > > > > * def* self.up > > > > add_column *:employees*, * :ssn*, *:string* > > > > * end* > > > > * def* self.down > > > > remove_column *:employees*, * :ssn* > > > > * end* > > > > *end* > > > > > > When I run this, however, I get: > > > > >rake db:migrate > > > > (in C:/workspace/hr) > > > > rake aborted! > > > > uninitialized constant Ssn > > > > > > > > I tried running with --trace but I don''t see how that helped. I did > > have the migration syntax wrong a couple of times, but now even though I > > think it''s fine, it still doesn''t work. > > > > > > > > Any suggestions would be appreciated. > > > > > > > > I''m running Ruby 1.8.4 with Rails 1.1.2 on Windows, btw. > > > > > > > > Ken Kousen > > -- > > Kenneth A. Kousen, Ph.D. > > President > > Kousen IT, Inc. > > http://www.kousenit.com > > ken.kousen@kousenit.com > > ------------------------------ > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060516/558beb24/attachment.html