Bug 1276039 - Postgres upgrade script (bpms-6.0-to-6.1.sql): null value in column "id" violates not-null constraint
Summary: Postgres upgrade script (bpms-6.0-to-6.1.sql): null value in column "id" viol...
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BPMS Platform 6
Classification: Retired
Component: jBPM Core
Version: 6.1.0
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: CR1
: 6.2.0
Assignee: Kris Verlaenen
QA Contact: Tibor Zimanyi
URL:
Whiteboard:
Depends On: 1235091
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-10-28 13:34 UTC by Alexandre Cavalcanti
Modified: 2020-03-27 19:13 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-27 19:13:38 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Dump to use on your tests (2.56 MB, application/x-gzip)
2015-10-28 13:34 UTC, Alexandre Cavalcanti
no flags Details

Description Alexandre Cavalcanti 2015-10-28 13:34:57 UTC
Created attachment 1087251 [details]
Dump to use on your tests

* Description of problem:

Using the database dump attached I ran the migration script [1] I the error [2] was shown.

[1] - https://github.com/droolsjbpm/jbpm/blob/master/jbpm-installer/db/upgrade-scripts/postgresql/bpms-6.0-to-6.1.sql
[2] - ERROR: null value in column "id" violates not-null constraint SQL state: 23502

* Version-Release number of selected component (if applicable):

I was migrating from 6.0.3 to 6.1.3 using Postgres 9.2

* How reproducible:

You don't need Jboss BPMS to reproduce this. Just install Postgres 9.2

* Steps to Reproduce:

On Postgres 9.2:
- Create a database;
- Import the dump attached;
- Try execute the whole upgrade script. 

* Actual results:

ERROR: null value in column "id" violates not-null constraint SQL state: 23502

* Expected results:

No errors

* Additional info:

As a workaround I changed the script, to link the id column (from the table AuditTaskImpl) to the sequence AUDIT_ID_SEQ (See [3]).

But I'm not sure if this is the best approach. If the persistence source code is putting the sequence using Hibernate this change which I made could lead to problems.

Better have an official solution to this from the experts.

-> Point of attention: In this change I placed single quotes in the nextval call but I got reports from people having the error because of this. So, if you got an error like [4] try remove the quote or put double quotes.

[3] - 
...
create table AuditTaskImpl (
        id int8 DEFAULT nextval('AUDIT_ID_SEQ') not null,
...

[4] - 
ERROR: relation “audit_id_seq” does not exist SQL state: 42P01

Comment 5 Alessandro Lazarotti 2015-10-29 00:29:59 UTC
Thank you Alexandre.
I was able to reproduce the issue.

Instead of using the sequence directly in the table definition the best should be using nextval in the INSERT statement to avid any problem with Hibernate.

I just created the PR bellow for Postgres and Oracle:
https://github.com/droolsjbpm/jbpm/pull/320/files

Comment 8 Tibor Zimanyi 2015-11-19 14:05:28 UTC
Verified in 6.2.0.CR1. The upgrade scripts from supplementary tools passed correctly and table AuditTaskImpl is filled with values. I used the attached PostgreSQL dump.


Note You need to log in before you can comment on or make changes to this bug.