I've manual inserted records in table customfieldvalue using sql.
for id value used construction "select max(id) from .."
db - postgresql
After inserting if i try to change some values in customfields in jira issues using jira web -interface, i get an error:
(SQL Exception while executing the following:INSERT INTO public.customfieldvalue (ID, ISSUE, CUSTOMFIELD, UPDATED, PARENTKEY, STRINGVALUE, NUMBERVALUE, TEXTVALUE, DATEVALUE, VALUETYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (ERROR: duplicate key value violates unique constraint "pk_customfieldvalue" Detail: Key (id)=(17600) already exists.))
It seems, jira have counter or sequence for it's table 'customfieldvalue', but how to set new actual correct value for this counter/sequence? How to get the name for this sequence?
The process for updating or adding to a Jira database with SQL is, at an absolute minimum:
Randomly jamming data into tables without a complete understanding of the database structure and how the code handles all the relationships is always going to go wrong.
You are right in recognising that there are sequences you have missed updates on. There could be one or several when you are adding custom field data, it depends entirely on the type of field.
It would be better if you could explain why you are trying to do this? We can probably give you a safe and easier route to achieve your goal if we knew what it is.
Hopefully @Jeff Tomband solution will work. You should NEVER directly interact with the database, it will usually require restoring a backup to fix the problem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah, Agreed (I wouldn't say never, but its risky).
But since he seems to have his mind set on it, or he has a good reason.
I'm also assuming he's doing it on a staging system first and performs a BU before actually running the inserts.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use something like this
VALUES ((SELECT ISNULL(MAX(ID) + 1,1) FROM XXXXXXXXXXX), ....
That should hopefully work
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.