the VERSION value at in rake db:migrate VERSION=[versionNumber] is the migration number right? for instance lets say I have 3 models generated in this respective order albums, users, and reviews. If I do "rake db:migrate VERSION=0", it will delete the data and existence of all three tables....if I do VERSION=1, it will delete the existance/ data of users and reviews etc etc... So my problem is I rolled back to VERSION=0, added a column to Review in the migration file, and migrated again. For some reason rails didn''t acknowledge the change and the table indecies are still the same. So my before I rolled back to version 0: class CreateReviews < ActiveRecord::Migration def self.up create_table :reviews, :force => true do |t| t.text :productReview t.string :product t.string :productCreator t.timestamps end end def self.down drop_table :reviews end end I then put in a coloumn called album_id class CreateReviews < ActiveRecord::Migration def self.up create_table :reviews, :force => true do |t| t.text :productReview t.string :product t.string :productCreator t.integer :album_id t.timestamps end end def self.down drop_table :reviews end end Rand db:migrate and checked my structure in the console and it''s still the previous version without album_id.... Any thoughts? --~--~---------~--~----~------------~-------~--~----~ 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 Fri, 2008-09-26 at 08:31 -0700, Jon wrote:> the VERSION value at in rake db:migrate VERSION=[versionNumber] is the > migration number right? for instance lets say I have 3 models > generated in this respective order albums, users, and reviews. If I > do "rake db:migrate VERSION=0", it will delete the data and existence > of all three tables....if I do VERSION=1, it will delete the existance/ > data of users and reviews etc etc... > > So my problem is I rolled back to VERSION=0, added a column to Review > in the migration file, and migrated again. For some reason rails > didn''t acknowledge the change and the table indecies are still the > same. > > So my before I rolled back to version 0: > > class CreateReviews < ActiveRecord::Migration > def self.up > create_table :reviews, :force => true do |t| > t.text :productReview > t.string :product > t.string :productCreator > > t.timestamps > end > > end > > def self.down > drop_table :reviews > end > end > > > I then put in a coloumn called album_id > > class CreateReviews < ActiveRecord::Migration > def self.up > create_table :reviews, :force => true do |t| > t.text :productReview > t.string :product > t.string :productCreator > t.integer :album_id > t.timestamps > end > > end > > def self.down > drop_table :reviews > end > end > > > Rand db:migrate and checked my structure in the console and it''s still > the previous version without album_id.... > > Any thoughts?---- The general idea is that when you want to change a model (i.e., add a column), that you created a new migration that adds the column to the table rather than migrate down and lose data. If however, you rake db:migrate VERSION=0, can you confirm indeed that the ''reviews'' table is indeed dropped? Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Craig, Yeah that sounds more feasible rather than migrating down...I can definitely confirm VERSION=0 will drop the table though because when try to load the structure in the console it throws me an error. What would be the syntax to just add a change(thus adding a new migration then) I want to add t.intger :album_id. I''m assuming it''s a command at the command line that will product and 004 migration file? Jon On Fri, Sep 26, 2008 at 8:43 AM, Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> > On Fri, 2008-09-26 at 08:31 -0700, Jon wrote: > > the VERSION value at in rake db:migrate VERSION=[versionNumber] is the > > migration number right? for instance lets say I have 3 models > > generated in this respective order albums, users, and reviews. If I > > do "rake db:migrate VERSION=0", it will delete the data and existence > > of all three tables....if I do VERSION=1, it will delete the existance/ > > data of users and reviews etc etc... > > > > So my problem is I rolled back to VERSION=0, added a column to Review > > in the migration file, and migrated again. For some reason rails > > didn''t acknowledge the change and the table indecies are still the > > same. > > > > So my before I rolled back to version 0: > > > > class CreateReviews < ActiveRecord::Migration > > def self.up > > create_table :reviews, :force => true do |t| > > t.text :productReview > > t.string :product > > t.string :productCreator > > > > t.timestamps > > end > > > > end > > > > def self.down > > drop_table :reviews > > end > > end > > > > > > I then put in a coloumn called album_id > > > > class CreateReviews < ActiveRecord::Migration > > def self.up > > create_table :reviews, :force => true do |t| > > t.text :productReview > > t.string :product > > t.string :productCreator > > t.integer :album_id > > t.timestamps > > end > > > > end > > > > def self.down > > drop_table :reviews > > end > > end > > > > > > Rand db:migrate and checked my structure in the console and it''s still > > the previous version without album_id.... > > > > Any thoughts? > ---- > The general idea is that when you want to change a model (i.e., add a > column), that you created a new migration that adds the column to the > table rather than migrate down and lose data. > > If however, you rake db:migrate VERSION=0, can you confirm indeed that > the ''reviews'' table is indeed dropped? > > Craig > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m sorry, it doesn''t throw me an error, it says Review(Table doesn''t exist) On Fri, Sep 26, 2008 at 8:58 AM, Jon Liu <jonliu81-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Craig, > > Yeah that sounds more feasible rather than migrating down...I can > definitely confirm VERSION=0 will drop the table though because when try to > load the structure in the console it throws me an error. > > What would be the syntax to just add a change(thus adding a new migration > then) > > I want to add t.intger :album_id. I''m assuming it''s a command at the > command line that will product and 004 migration file? > > Jon > > > On Fri, Sep 26, 2008 at 8:43 AM, Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org>wrote: > >> >> On Fri, 2008-09-26 at 08:31 -0700, Jon wrote: >> > the VERSION value at in rake db:migrate VERSION=[versionNumber] is the >> > migration number right? for instance lets say I have 3 models >> > generated in this respective order albums, users, and reviews. If I >> > do "rake db:migrate VERSION=0", it will delete the data and existence >> > of all three tables....if I do VERSION=1, it will delete the existance/ >> > data of users and reviews etc etc... >> > >> > So my problem is I rolled back to VERSION=0, added a column to Review >> > in the migration file, and migrated again. For some reason rails >> > didn''t acknowledge the change and the table indecies are still the >> > same. >> > >> > So my before I rolled back to version 0: >> > >> > class CreateReviews < ActiveRecord::Migration >> > def self.up >> > create_table :reviews, :force => true do |t| >> > t.text :productReview >> > t.string :product >> > t.string :productCreator >> > >> > t.timestamps >> > end >> > >> > end >> > >> > def self.down >> > drop_table :reviews >> > end >> > end >> > >> > >> > I then put in a coloumn called album_id >> > >> > class CreateReviews < ActiveRecord::Migration >> > def self.up >> > create_table :reviews, :force => true do |t| >> > t.text :productReview >> > t.string :product >> > t.string :productCreator >> > t.integer :album_id >> > t.timestamps >> > end >> > >> > end >> > >> > def self.down >> > drop_table :reviews >> > end >> > end >> > >> > >> > Rand db:migrate and checked my structure in the console and it''s still >> > the previous version without album_id.... >> > >> > Any thoughts? >> ---- >> The general idea is that when you want to change a model (i.e., add a >> column), that you created a new migration that adds the column to the >> table rather than migrate down and lose data. >> >> If however, you rake db:migrate VERSION=0, can you confirm indeed that >> the ''reviews'' table is indeed dropped? >> >> Craig >> >> >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 Fri, 2008-09-26 at 08:58 -0700, Jon Liu wrote:> Craig, > > Yeah that sounds more feasible rather than migrating down...I can > definitely confirm VERSION=0 will drop the table though because when > try to load the structure in the console it throws me an error. > > What would be the syntax to just add a change(thus adding a new > migration then) > > I want to add t.intger :album_id. I''m assuming it''s a command at the > command line that will product and 004 migration file?---- something like this in the migration... def self.up add_column :reviews, :album_id, :integer end def self.down remove_column :reviews, :album_id end Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ok thanks, but how do you actually generate that particular migrations file from the command line?, ie it would be 004_something On Fri, Sep 26, 2008 at 9:31 AM, Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> > On Fri, 2008-09-26 at 08:58 -0700, Jon Liu wrote: > > Craig, > > > > Yeah that sounds more feasible rather than migrating down...I can > > definitely confirm VERSION=0 will drop the table though because when > > try to load the structure in the console it throws me an error. > > > > What would be the syntax to just add a change(thus adding a new > > migration then) > > > > I want to add t.intger :album_id. I''m assuming it''s a command at the > > command line that will product and 004 migration file? > ---- > something like this in the migration... > > def self.up > add_column :reviews, :album_id, :integer > end > > def self.down > remove_column :reviews, :album_id > end > > Craig > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Fri, 2008-09-26 at 09:33 -0700, Jon Liu wrote:> ok thanks, but how do you actually generate that particular migrations > file from the command line?, ie it would be 004_something >---- script/generate migration some_name_of_what_you_re_trying_to_accomplish Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks craig, I was able to generate the file w/the command and I added the "add_column" code. When I do my migrate I can see rail iteratively compiling the files and I see the 4 add_column(:reviews, :album_id, :integer) ->.2970s 4 AddAlbumIdToReviews: migrated (0.3120s) which means that''s it''s been migrated. But when i look at my Review structure in the console window the it still doesn''t show up...any more thoughts? On Fri, Sep 26, 2008 at 9:43 AM, Craig White <craigwhite-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> > On Fri, 2008-09-26 at 09:33 -0700, Jon Liu wrote: > > ok thanks, but how do you actually generate that particular migrations > > file from the command line?, ie it would be 004_something > > > ---- > script/generate migration some_name_of_what_you_re_trying_to_accomplish > > Craig > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Sep 27, 1:04 am, "Jon Liu" <jonli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> thanks craig, > > I was able to generate the file w/the command and I added the "add_column" > code. When I do my migrate I can see rail iteratively compiling the files > and I see the > > 4 add_column(:reviews, :album_id, :integer) > ->.2970s > 4 AddAlbumIdToReviews: migrated (0.3120s) > > which means that''s it''s been migrated. But when i look at my Review > structure in the console window the it still doesn''t show up...any more > thoughts?Just curious: how are you viewing the structure via the console? Are you looking at an already loaded instance via the ruby console, like:> review = Review.find(:first) > reviewOr are you viewing it via your db''s console? --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m just loading it like this:>>ReviewReview(id: integer, productReview:text, product: string, productCreator: string, created_at: datetime, updated_at: datetime) It''s strange, I added an identical id to another structure called Album, well I added "review_id", and it worked out fine. On Fri, Sep 26, 2008 at 10:28 AM, Erol Fornoles <erol.fornoles-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > On Sep 27, 1:04 am, "Jon Liu" <jonli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > thanks craig, > > > > I was able to generate the file w/the command and I added the > "add_column" > > code. When I do my migrate I can see rail iteratively compiling the > files > > and I see the > > > > 4 add_column(:reviews, :album_id, :integer) > > ->.2970s > > 4 AddAlbumIdToReviews: migrated (0.3120s) > > > > which means that''s it''s been migrated. But when i look at my Review > > structure in the console window the it still doesn''t show up...any more > > thoughts? > > Just curious: how are you viewing the structure via the console? Are > you looking at an already loaded instance via the ruby console, like: > > > review = Review.find(:first) > > review > > Or are you viewing it via your db''s console? > > >--~--~---------~--~----~------------~-------~--~----~ 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 Sep 27, 1:33 am, "Jon Liu" <jonli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m just loading it like this: > > >>Review > > Review(id: integer, productReview:text, product: string, productCreator: > string, created_at: datetime, updated_at: datetime) > > It''s strange, I added an identical id to another structure called Album, > well I added "review_id", and it worked out fine.Have you tried restarting the console after you ran the migration? --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
you know that might be a good idea... On Fri, Sep 26, 2008 at 10:37 AM, Erol Fornoles <erol.fornoles-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> > > > On Sep 27, 1:33 am, "Jon Liu" <jonli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''m just loading it like this: > > > > >>Review > > > > Review(id: integer, productReview:text, product: string, productCreator: > > string, created_at: datetime, updated_at: datetime) > > > > It''s strange, I added an identical id to another structure called Album, > > well I added "review_id", and it worked out fine. > > Have you tried restarting the console after you ran the migration? > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Craig, It worked. Thank you....please excuse me while I go shoot myself for not trying that already. It''s funny restarting the console has worked in some instances like this before...but I was lazy and did "reload!" instead. Rails is funny... Thanks again Jon On Fri, Sep 26, 2008 at 10:38 AM, Jon Liu <jonliu81-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you know that might be a good idea... > > > On Fri, Sep 26, 2008 at 10:37 AM, Erol Fornoles <erol.fornoles-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> >> >> >> On Sep 27, 1:33 am, "Jon Liu" <jonli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > I''m just loading it like this: >> > >> > >>Review >> > >> > Review(id: integer, productReview:text, product: string, productCreator: >> > string, created_at: datetime, updated_at: datetime) >> > >> > It''s strange, I added an identical id to another structure called Album, >> > well I added "review_id", and it worked out fine. >> >> Have you tried restarting the console after you ran the migration? >> >> >> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---