I was following this set of instructions from the "Cookie overflow?" thread:> Your sessions (by default in cookie) needs to be moved to Active record > store or memcache store to fix this issue. > > For Databased sessions: > config.action_controller.session_store = :active_record_store > You need to create the session table as below > rake db:sessions:create > rake db:migrateI added the config line to environment.rb; is that the approriate place? When I ran the migration, I got rake aborted! An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "artists" already exists: [etc] So I removed the existing, populated database (to a safe place, since I do not want to have to create it again unless necessary) and ran the rake db:migrate again...clearly there is something I don''t understand because most sane people would want to preserve the contents of an existing db when they modify it. Now I have a problem, because of course the new (empty) database has an extra table in it. Before I go and write a ruby script to create a database containing my old records + the new table as it appears in schema.rb, is there not a simpler, more sensible way to do this? If I do have to remake the db manually, can anyone answer a questions for me regarding the session table: Does it also use a column "id" as the INTEGER PRIMARY KEY? I suppose it won''t matter if it doesn''t and I put one in anyway... -- Posted via http://www.ruby-forum.com/.
On Wed, May 27, 2009 at 7:34 AM, Mk 27 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> When I ran the migration, I got > > rake aborted! > An error has occurred, this and all later migrations canceled: > > SQLite3::SQLException: table "artists" already exists: [etc] > > So I removed the existing, populated database (to a safe place, since I > do not want to have to create it again unless necessary) and ran the > rake db:migrate again...clearly there is something I don''t understand > because most sane people would want to preserve the contents of an > existing db when they modify it.Erm, so maybe the most appropriate ("sane") thing to do at that point would be to figure out *why* you''re (apparently) repeating a migration that''s already been done? Just sayin'' ... :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
This would suggest that the migration you were running was attempting to add the artists table. I think this is nothing to do with rake db:sessions:create. Have a look in the migration made by the rake to see what it is doing. I imagine that you have an earlier migration that created the artists table and for some reason that is running again. Colin 2009/5/27 Mk 27 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > I was following this set of instructions from the "Cookie overflow?" > thread: > > > Your sessions (by default in cookie) needs to be moved to Active record > > store or memcache store to fix this issue. > > > > For Databased sessions: > > config.action_controller.session_store = :active_record_store > > You need to create the session table as below > > rake db:sessions:create > > rake db:migrate > > I added the config line to environment.rb; is that the approriate place? > > When I ran the migration, I got > > rake aborted! > An error has occurred, this and all later migrations canceled: > > SQLite3::SQLException: table "artists" already exists: [etc] > > So I removed the existing, populated database (to a safe place, since I > do not want to have to create it again unless necessary) and ran the > rake db:migrate again...clearly there is something I don''t understand > because most sane people would want to preserve the contents of an > existing db when they modify it. > > Now I have a problem, because of course the new (empty) database has an > extra table in it. Before I go and write a ruby script to create a > database containing my old records + the new table as it appears in > schema.rb, is there not a simpler, more sensible way to do this? > > If I do have to remake the db manually, can anyone answer a questions > for me regarding the session table: Does it also use a column "id" as > the INTEGER PRIMARY KEY? I suppose it won''t matter if it doesn''t and I > put one in anyway... > -- > 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 -~----------~----~----~----~------~----~------~--~---
And check the schema_migrations table in the database. Maybe an older database was restored from a backup for some reason. On May 27, 2:02 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> This would suggest that the migration you were running was attempting to add > the artists table. I think this is nothing to do with rake > db:sessions:create. Have a look in the migration made by the rake to see > what it is doing. I imagine that you have an earlier migration that created > the artists table and for some reason that is running again. > > Colin > > 2009/5/27 Mk 27 <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > > > > I was following this set of instructions from the "Cookie overflow?" > > thread: > > > > Your sessions (by default in cookie) needs to be moved to Active record > > > store or memcache store to fix this issue. > > > > For Databased sessions: > > > config.action_controller.session_store = :active_record_store > > > You need to create the session table as below > > > rake db:sessions:create > > > rake db:migrate > > > I added the config line to environment.rb; is that the approriate place? > > > When I ran the migration, I got > > > rake aborted! > > An error has occurred, this and all later migrations canceled: > > > SQLite3::SQLException: table "artists" already exists: [etc] > > > So I removed the existing, populated database (to a safe place, since I > > do not want to have to create it again unless necessary) and ran the > > rake db:migrate again...clearly there is something I don''t understand > > because most sane people would want to preserve the contents of an > > existing db when they modify it. > > > Now I have a problem, because of course the new (empty) database has an > > extra table in it. Before I go and write a ruby script to create a > > database containing my old records + the new table as it appears in > > schema.rb, is there not a simpler, more sensible way to do this? > > > If I do have to remake the db manually, can anyone answer a questions > > for me regarding the session table: Does it also use a column "id" as > > the INTEGER PRIMARY KEY? I suppose it won''t matter if it doesn''t and I > > put one in anyway... > > -- > > Posted viahttp://www.ruby-forum.com/.
Also, check the schema_migrations table in your database to see what migration it thinks you last ran. On May 27, 2:02 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> This would suggest that the migration you were running was attempting to add > the artists table. I think this is nothing to do with rake > db:sessions:create. Have a look in the migration made by the rake to see > what it is doing. I imagine that you have an earlier migration that created > the artists table and for some reason that is running again. > > Colin > > 2009/5/27 Mk 27 <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > > > > I was following this set of instructions from the "Cookie overflow?" > > thread: > > > > Your sessions (by default in cookie) needs to be moved to Active record > > > store or memcache store to fix this issue. > > > > For Databased sessions: > > > config.action_controller.session_store = :active_record_store > > > You need to create the session table as below > > > rake db:sessions:create > > > rake db:migrate > > > I added the config line to environment.rb; is that the approriate place? > > > When I ran the migration, I got > > > rake aborted! > > An error has occurred, this and all later migrations canceled: > > > SQLite3::SQLException: table "artists" already exists: [etc] > > > So I removed the existing, populated database (to a safe place, since I > > do not want to have to create it again unless necessary) and ran the > > rake db:migrate again...clearly there is something I don''t understand > > because most sane people would want to preserve the contents of an > > existing db when they modify it. > > > Now I have a problem, because of course the new (empty) database has an > > extra table in it. Before I go and write a ruby script to create a > > database containing my old records + the new table as it appears in > > schema.rb, is there not a simpler, more sensible way to do this? > > > If I do have to remake the db manually, can anyone answer a questions > > for me regarding the session table: Does it also use a column "id" as > > the INTEGER PRIMARY KEY? I suppose it won''t matter if it doesn''t and I > > put one in anyway... > > -- > > Posted viahttp://www.ruby-forum.com/.
Hassan Schroeder wrote:> On Wed, May 27, 2009 at 7:34 AM, Mk 27 > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> because most sane people would want to preserve the contents of an >> existing db when they modify it. > > Erm, so maybe the most appropriate ("sane") thing to do at that > point would be to figure out *why* you''re (apparently) repeating a > migration that''s already been done?There was an existing database, yes, I thought that was clear. The reason I did it again was (also clear if you can read, but to repeat) because I wanted to move the session store to Active Record so I was following this instruction:> You need to create the session table as below > rake db:sessions:create > rake db:migrateWhich I am grateful for that advice, because it worked; but I did have to create the db manually (because I want it populated, and already have a script to do that), add the session table myself (to the aforementioned script), and insert it back in. So I guess I don''t get the point of the migration thing yet: is it more for people who don''t want to create a db themself, or what? Nb, this is my second casual week using rails. If all I want to do is add a table to the database, why would it want to rebuild the whole thing, ie, why not just add the new table and leave the existing tables alone? I presume there is away to do this and I haven''t read enough of the API docs yet. Is this going against "the convention", hence I needed to do some more "configuration"? -- Posted via http://www.ruby-forum.com/.
On Wed, May 27, 2009 at 3:35 PM, Mk 27 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> There was an existing database, yes, I thought that was clear. The > reason I did it again wasYes, yes, entirely clear, and totally irrelevant to the issue.> Which I am grateful for that advice, because it worked; but I did have > to create the db manually (because I want it populated, and already have > a script to do that), add the session table myself (to the > aforementioned script), and insert it back in.No, you didn''t - that''s the whole point :-)> So I guess I don''t get the point of the migration thing yet:Apparently -- so, seriously, read up on migrations before you go any further. You''ll save yourself a lot of headaches down the road. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Hassan Schroeder wrote:> nothing of interest to me eitherThanks for your non-advice! ;) -- Posted via http://www.ruby-forum.com/.
On Wed, May 27, 2009 at 4:03 PM, Mk 27 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:>> nothing of interest to me either > > Thanks for your non-advice!Where did I say that? Must be some cross-talk in your mail client :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Mk 27 wrote:> Hassan Schroeder wrote: > >> nothing of interest to me either > > Thanks for your non-advice! > > ;)Hassan gave you some excellent advice. Read it again -- and this time, if you want to learn, I suggest that you ask instead of hurling insults. (I also suggest that an apology to Hassan might be in order, but that''s between you and him.) Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
2009/5/27 Mk 27 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > Hassan Schroeder wrote: > > On Wed, May 27, 2009 at 7:34 AM, Mk 27 > > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > >> because most sane people would want to preserve the contents of an > >> existing db when they modify it. > > > > Erm, so maybe the most appropriate ("sane") thing to do at that > > point would be to figure out *why* you''re (apparently) repeating a > > migration that''s already been done? > > There was an existing database, yes, I thought that was clear. The > reason I did it again was (also clear if you can read, but to repeat) > because I wanted to move the session store to Active Record so I was > following this instruction: > > > You need to create the session table as below > > rake db:sessions:create > > rake db:migrate > > Which I am grateful for that advice, because it worked; but I did have > to create the db manually (because I want it populated, and already have > a script to do that), add the session table myself (to the > aforementioned script), and insert it back in. So I guess I don''t get > the point of the migration thing yet: is it more for people who don''t > want to create a db themself, or what? > > Nb, this is my second casual week using rails. If all I want to do is > add a table to the database, why would it want to rebuild the whole > thing, ie, why not just add the new table and leave the existing tables > alone? I presume there is away to do this and I haven''t read enough of > the API docs yet.You have hit the nail on the head here, that is exactly what migrations will do for you (ie "add the new table and leave the existing tables alone") in addition to other things of course. Colin> Is this going against "the convention", hence I > needed to do some more "configuration"? > > -- > 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 -~----------~----~----~----~------~----~------~--~---