[development] Updating to D6 change from db_next_id to serial columns

Richard Morse remorse at partners.org
Thu Aug 13 14:16:43 UTC 2009


Hi! Yes, I know I'm a horrible person to only now be updating a module  
to D6.  Please forgive me.

I am porting a module to Drupal 6 which used the `db_next_id()`  
function to get primary keys for a table. I would like to switch over  
to using autoincrement/db sequences (ie, schema type of 'serial') for  
this table. However, I need to provide an upgrade path. I've done a  
number of Google and Drupal.org searches, I've looked at  
taxonomy.install and system.install, and I can't seem to find any  
examples of where a column was upgraded from an old D5-style int-with- 
db_next_id-value to a serial. Are there any examples? I'd rather use a  
"best practices" method than a roll-my-own method.

If there are none, I'm assuming the proper way to do it is to rename  
the tables, find the max of the old primary key, create the new  
tables, insert bogus rows until I hit the max value, delete currently  
unused values, copy over the current data, and then delete the old  
tables?

Thanks,
Ricky


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



More information about the development mailing list