Hi all, I am new to ROR and I use RadRails for ROR. I start a project and create a model,a scaffold, and a table. It works fine. The table contains two columns. Later on I need to add one more column to the table and I find I can''t update the table. I wonder if anyone out there please gives me a hand. Thanks, Li ############# original table with 2 columns in file db\migrate\001_create_employees.rb class CreateEmployees < ActiveRecord::Migration def self.up create_table :employees do |t| t.column :name,:string t.column :hiredate,:date end end def self.down drop_table :employees end end ########### in file db\schema.rb ActiveRecord::Schema.define(:version => 1) do create_table "employees", :force => true do |t| t.column "name", :string t.column "hiredate", :date end end ######later on add one more column to the new table class CreateEmployees < ActiveRecord::Migration def self.up create_table :employees do |t| t.column :name,:string t.column :hiredate,:date t.column :salary,:float end end def self.down drop_table :employees end end ########### in file db\schema.rb ActiveRecord::Schema.define(:version => 1) do create_table "employees", :force => true do |t| t.column "name", :string t.column "hiredate", :date end end ##there is no change to the schema.rb. WHY??? and how? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, 31 Dec 2007 16:44:20 +0100, Li Chen wrote:> I am new to ROR and I use RadRails for ROR. I start a project and create > a model,a scaffold, and a table. It works fine. The table contains two > columns. Later on I need to add one more column to the table and I find > I can''t update the table. I wonder if anyone out there please gives me a > hand.Get a second opinion first. Err, I mean, run this by a more experience RoR person. try: rake db:migrate VERSION=0 rake db:migrate the first command will drop the tables, the second command will re-create the tables. Data will be lost. Data will be lost. Data will be lost. Data will be lost. Data will be lost. Data will be lost. Data will be lost. Data will be lost. Data will be lost. Data will be lost. -Thufir --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, it two ways that you can do it: Not So The Rails Way a) rake db:migrate VERSION=0 b) edit and save the migration beginning with "001_" c) rake db:migrate More So The Rails Way a) script/generate migration <the_name_of_my_migration_file> b) edit and save the migration file that has been generated. Note: If you need info on how to properly add a column, please consult pages 260 - 265 of AWDwR2. Good luck, -Conrad On Dec 31, 2007 8:39 AM, Thufir <hawat.thufir-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Mon, 31 Dec 2007 16:44:20 +0100, Li Chen wrote: > > > I am new to ROR and I use RadRails for ROR. I start a project and create > > a model,a scaffold, and a table. It works fine. The table contains two > > columns. Later on I need to add one more column to the table and I find > > I can''t update the table. I wonder if anyone out there please gives me a > > hand. > > > > Get a second opinion first. Err, I mean, run this by a more experience > RoR person. try: > > rake db:migrate VERSION=0 > rake db:migrate > > > > the first command will drop the tables, the second command will re-create > the tables. Data will be lost. Data will be lost. Data will be lost. > Data will be lost. Data will be lost. Data will be lost. Data will be > lost. Data will be lost. Data will be lost. Data will be lost. > > > > -Thufir > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---