I have a custom module, built in Module builder, that has a contract_number autoincrement field.
'contract_number' =>
array (
'type'=>'int',
'required' => true,
'name' => 'contract_number',
'vname' => 'LBL_CONTRACT_NUMBER',
'readonly' => true,
'len' => '11',
'required' => true,
'auto_increment' => true,
'unified_search' => true,
'full_text_search' =>
array (
'boost' => '3',
'enabled' => true,
),
'comment' => 'Visual unique identifier',
'duplicate_merge' => 'disabled',
'disable_num_format' => '1',
'duplicate_on_record_copy' => 'no',
'audited' => false,
'massupdate' => false,
'merge_filter' => 'disabled',
'calculated' => false,
'enable_range_search' => false,
'min' => false,
'max' => false,
),
I disabled auto_increment it to upload some old records from another system for which I needed to preserve the contract_number.
During the upload (a script that generated and saved beans) I also commented out the auto_increment=>true from the metadata file above.
When I tried re-enabling the auto increment I set the auto_increment=>true and in studio set the autoincrement next value at 10000
I also attempted to reset the auto_increment on the table:
alter table wcont_wolframcontracts modify column contract_number int(255) auto_increment
alter table wcont_wolframcontracts AUTO_INCREMENT = 10000;
but got an error at the db level:
Error Code: 1062. Duplicate entry '7260' for key 'contract_number'
But that is the max contract_number in the table and I'm starting again from 10000
select max(contract_number) from wcont_wolframcontracts returns 7260
The result is that the field is not populating at all for new records.
So am I going about this all wrong? What is the appropriate way to define an auto_increment field and ask it to override the auto_increment when creating records from scripts for the initial upload of old records?
thanks,
Francesca