Also, let say you have delete a bunch of record and you want to keep a sequential ID incrementation for some reason, nothing prevent you to update your backend sequence start parameter and rewind to the last ID surrogate number so next time you insert a record you will have consecutive ID...
Doc for manipulating sequence with postgresql : http://www.postgresql.org/docs/9.1/static/sql-altersequence.html You can also reset the sequence entirely if you want to start fresh for with a testing database for instance you can even automate this in a teardown process after each test run... Richard On Tue, Nov 3, 2015 at 2:14 PM, Richard Vézina <ml.richard.vez...@gmail.com> wrote: > I think Alex concern is about if he can reuse ID 1 which seems he deleted > and now would reuse it for storing other information... > > If I am correct, this is possible as long as the ID 1 is effectively empty > and if there is no history attach the record (though, this is not so a > problem neither depending of how you use the historic data). So as long as > you don't use web2py versioning feature you can do that safetly after you > make it sure that ID 1 (for example) is effectively empty... > > db(db.auth_user.id == 1).insert(...) > db.commit() > > From the command line in web2py shell... Or you may use an update form and > pass to the controller the ID which will update an empty record with the ID > 1 with the data you will input and submit... > > Richard > > On Tue, Nov 3, 2015 at 2:02 PM, Jim S <j...@qlf.com> wrote: > >> If I understand your question properly, I think Record Versioning could >> do it. >> >> >> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Record-versioning >> >> If you 'deleted' auth_user.id == 1, all that happens then is that the >> is_active field gets set to False. You could then search for it and make >> your updates as it didn't really get deleted from the DB. Then just change >> is_active back to True. >> >> -Jim >> >> >> On Tuesday, November 3, 2015 at 12:25:07 PM UTC-6, Alex Glaros wrote: >>> >>> I'd lilke to reuse a primary key that has been deleted >>> >>> For example, I'd like to take deleted auth_user.id == 1, and change the >>> first_name and other field data in it for reuse. >>> >>> Same for other tables, for example, db.Organization.id ==1, would like >>> to replace old org name with "Department of Motor Vehicles" >>> >>> Those primary keys have been deleted and records are not accessible so I >>> can't edit them. >>> >>> The only way I can think of doing it is to drop table and re-enter data >>> in correct order. >>> >>> thanks, >>> >>> Alex Glaros >>> >> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to the Google Groups >> "web2py-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.