# Error in adding a relationship with tracker capture app

**URL:** <https://community.dhis2.org/t/error-in-adding-a-relationship-with-tracker-capture-app/29438>\
**Category:** Support - Assistance technique\
**Created:** [25 June 2015 10:37 UTC](https://community.dhis2.org/t/error-in-adding-a-relationship-with-tracker-capture-app/29438 "2015-06-25T10:37:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/jason/32/32739_2.png) [@jason](https://community.dhis2.org/u/jason)\
**Post date:** [25 June 2015 10:37 UTC](https://community.dhis2.org/t/error-in-adding-a-relationship-with-tracker-capture-app/29438/1 "2015-06-25T10:37:42Z")

</div>

I have posted the full stack trace here. Occurs when attempting to save a new relationship.

[http://pastebin.com/ap1XxWea](http://pastebin.com/ap1XxWea)

Version:  
2.19  
Build revision:  
19247

Regards,  
Jason

---

<div class="post-metadata">

**Author:** ![Abyot\_Gizaw](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/abyot_gizaw/32/40289_2.png) [@Abyot\_Gizaw](https://community.dhis2.org/u/Abyot_Gizaw)\
**Post date:** [25 June 2015 13:11 UTC](https://community.dhis2.org/t/error-in-adding-a-relationship-with-tracker-capture-app/29438/2 "2015-06-25T13:11:54Z")

</div>

Hi Jason,

Seems a database issue… it complains about missing “patientaid”. Is this really a 2.19 db?

Thank you,

Abyot.

> **···**
>
> On Thu, Jun 25, 2015 at 12:37 PM Jason Pickering [jason.p.pickering@gmail.com](mailto:jason.p.pickering@gmail.com) wrote:
> 
> > I have posted the full stack trace here. Occurs when attempting to save a new relationship.
> 
> > [http://pastebin.com/ap1XxWea](http://pastebin.com/ap1XxWea)
> 
> > 
> 
> > Version:  
> > 2.19  
> > Build revision:  
> > 19247
> > 
> > Regards,  
> > Jason
> 
> > 
> 
> > * * *
> > 
> > Mailing list: [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > 
> > Post to : [dhis2-devs@lists.launchpad.net](mailto:dhis2-devs@lists.launchpad.net)
> > 
> > Unsubscribe : [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > 
> > More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)
> 
> –
> 
> * * *
> 
> Thank you,
> 
> Abyot

---

<div class="post-metadata">

**Author:** ![jason](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/jason/32/32739_2.png) [@jason](https://community.dhis2.org/u/jason)\
**Post date:** [25 June 2015 13:17 UTC](https://community.dhis2.org/t/error-in-adding-a-relationship-with-tracker-capture-app/29438/3 "2015-06-25T13:17:02Z")

</div>

It has been upgraded from and earlier version. Maybe this needs to be deleted or missing in an upgrade script?

> **···**
>
> On Thu, Jun 25, 2015, 15:12 Abyot Gizaw [abyota@gmail.com](mailto:abyota@gmail.com) wrote:
> 
> > Hi Jason,
> 
> > Seems a database issue… it complains about missing “patientaid”. Is this really a 2.19 db?
> 
> > 
> 
> > Thank you,
> 
> > Abyot.
> 
> > 
> 
> > On Thu, Jun 25, 2015 at 12:37 PM Jason Pickering [jason.p.pickering@gmail.com](mailto:jason.p.pickering@gmail.com) wrote:
> 
> > > I have posted the full stack trace here. Occurs when attempting to save a new relationship.
> 
> > > [http://pastebin.com/ap1XxWea](http://pastebin.com/ap1XxWea)
> 
> > >
> 
> > > Version:  
> > > 2.19  
> > > Build revision:  
> > > 19247
> > > 
> > > Regards,  
> > > Jason
> 
> > >
> 
> > > * * *
> > > 
> > > Mailing list: [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > > 
> > > Post to : [dhis2-devs@lists.launchpad.net](mailto:dhis2-devs@lists.launchpad.net)
> > > 
> > > Unsubscribe : [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > > 
> > > More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)
> 
> > –
> 
> > * * *
> > 
> > Thank you,
> 
> > Abyot

---

<div class="post-metadata">

**Author:** ![Abyot\_Gizaw](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/abyot_gizaw/32/40289_2.png) [@Abyot\_Gizaw](https://community.dhis2.org/u/Abyot_Gizaw)\
**Post date:** [25 June 2015 13:32 UTC](https://community.dhis2.org/t/error-in-adding-a-relationship-with-tracker-capture-app/29438/4 "2015-06-25T13:32:37Z")

</div>

Yes the upgrade script was supposed to take care of that. Try to manually clear and see if the error goed.

See here [https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/rename-patient-to-trackedentity.sql](https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/rename-patient-to-trackedentity.sql)

– relationship

```auto
ALTER TABLE relationship RENAME COLUMN patientaid TO trackedentityinstanceaid;
ALTER TABLE relationship RENAME COLUMN patientbid TO trackedentityinstancebid;
ALTER TABLE relationship RENAME CONSTRAINT fk_relationship_patientida TO fk_relationship_trackedentityinstanceida;
ALTER TABLE relationship RENAME CONSTRAINT fk_relationship_patientidb TO fk_relationship_trackedentityinstanceidb;

```

> **···**
>
> On Thu, Jun 25, 2015 at 3:17 PM Jason Pickering [jason.p.pickering@gmail.com](mailto:jason.p.pickering@gmail.com) wrote:
> 
> > It has been upgraded from and earlier version. Maybe this needs to be deleted or missing in an upgrade script?
> 
> > On Thu, Jun 25, 2015, 15:12 Abyot Gizaw [abyota@gmail.com](mailto:abyota@gmail.com) wrote:
> 
> > > Hi Jason,
> 
> > > Seems a database issue… it complains about missing “patientaid”. Is this really a 2.19 db?
> 
> > >
> 
> > > Thank you,
> 
> > > Abyot.
> 
> > >
> 
> > > On Thu, Jun 25, 2015 at 12:37 PM Jason Pickering [jason.p.pickering@gmail.com](mailto:jason.p.pickering@gmail.com) wrote:
> 
> > > > I have posted the full stack trace here. Occurs when attempting to save a new relationship.
> 
> > > > [http://pastebin.com/ap1XxWea](http://pastebin.com/ap1XxWea)
> 
> > > >
> 
> > > > Version:  
> > > > 2.19  
> > > > Build revision:  
> > > > 19247
> > > > 
> > > > Regards,  
> > > > Jason
> 
> > > >
> 
> > > > * * *
> > > > 
> > > > Mailing list: [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > > > 
> > > > Post to : [dhis2-devs@lists.launchpad.net](mailto:dhis2-devs@lists.launchpad.net)
> > > > 
> > > > Unsubscribe : [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > > > 
> > > > More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)
> 
> > > –
> 
> > > * * *
> > > 
> > > Thank you,
> 
> > > Abyot
> 
> –
> 
> * * *
> 
> Thank you,
> 
> Abyot

---

<div class="post-metadata">

**Author:** ![jason](https://dhis2.b-cdn.net/user_avatar/community.dhis2.org/jason/32/32739_2.png) [@jason](https://community.dhis2.org/u/jason)\
**Post date:** [25 June 2015 16:31 UTC](https://community.dhis2.org/t/error-in-adding-a-relationship-with-tracker-capture-app/29438/5 "2015-06-25T16:31:45Z")

</div>

That did not work, but this did

ALTER TABLE relationship DROP COLUMN patientaid;

ALTER TABLE relationship DROP COLUMN patientbid;

Does this point to potentially other problems, perhaps like a missed upgrade script or problems with the startup routines which alter the tables?

Regards,

Jason

> **···**
>
> On Thu, Jun 25, 2015 at 3:32 PM, Abyot Gizaw [abyota@gmail.com](mailto:abyota@gmail.com) wrote:
> 
> > Yes the upgrade script was supposed to take care of that. Try to manually clear and see if the error goed.
> 
> > See here [https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/rename-patient-to-trackedentity.sql](https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/rename-patient-to-trackedentity.sql)
> 
> > 
> 
> > – relationship
> 
> > ```auto
> > ALTER TABLE relationship RENAME COLUMN patientaid TO trackedentityinstanceaid;
> > ALTER TABLE relationship RENAME COLUMN patientbid TO trackedentityinstancebid;
> > ALTER TABLE relationship RENAME CONSTRAINT fk_relationship_patientida TO fk_relationship_trackedentityinstanceida;
> > ALTER TABLE relationship RENAME CONSTRAINT fk_relationship_patientidb TO fk_relationship_trackedentityinstanceidb;
> > 
> > ```
> 
> > 
> 
> > 
> 
> > On Thu, Jun 25, 2015 at 3:17 PM Jason Pickering [jason.p.pickering@gmail.com](mailto:jason.p.pickering@gmail.com) wrote:
> 
> > > It has been upgraded from and earlier version. Maybe this needs to be deleted or missing in an upgrade script?
> 
> > > On Thu, Jun 25, 2015, 15:12 Abyot Gizaw [abyota@gmail.com](mailto:abyota@gmail.com) wrote:
> 
> > > > Hi Jason,
> 
> > > > Seems a database issue… it complains about missing “patientaid”. Is this really a 2.19 db?
> 
> > > >
> 
> > > > Thank you,
> 
> > > > Abyot.
> 
> > > >
> 
> > > > On Thu, Jun 25, 2015 at 12:37 PM Jason Pickering [jason.p.pickering@gmail.com](mailto:jason.p.pickering@gmail.com) wrote:
> 
> > > > > I have posted the full stack trace here. Occurs when attempting to save a new relationship.
> 
> > > > > [http://pastebin.com/ap1XxWea](http://pastebin.com/ap1XxWea)
> 
> > > > >
> 
> > > > > Version:  
> > > > > 2.19  
> > > > > Build revision:  
> > > > > 19247
> > > > > 
> > > > > Regards,  
> > > > > Jason
> 
> > > > >
> 
> > > > > * * *
> > > > > 
> > > > > Mailing list: [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > > > > 
> > > > > Post to : [dhis2-devs@lists.launchpad.net](mailto:dhis2-devs@lists.launchpad.net)
> > > > > 
> > > > > Unsubscribe : [https://launchpad.net/~dhis2-devs](https://launchpad.net/~dhis2-devs)
> > > > > 
> > > > > More help : [https://help.launchpad.net/ListHelp](https://help.launchpad.net/ListHelp)
> 
> > > > –
> 
> > > > * * *
> > > > 
> > > > Thank you,
> 
> > > > Abyot
> 
> > –
> 
> > * * *
> > 
> > Thank you,
> 
> > Abyot
> 
> –
> 
> Jason P. Pickering  
> email: [jason.p.pickering@gmail.com](mailto:jason.p.pickering@gmail.com)  
> tel:+46764147049
