# AutoGenerationOption has no UUID

**URL:** <https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431>\
**Category:** Development\
**Tags:** idgen\
**Created:** [March 16, 2020, 8:53am UTC](https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431 "2020-03-16T08:53:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [March 16, 2020, 8:53am UTC](https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431/1 "2020-03-16T08:53:32Z")

</div>

Hi all,

I’m working on [adding new domain and implementation for `AutoGenerationOption`](https://github.com/mekomsolutions/openmrs-module-initializer/issues/50), the practical challenge I have encountered with the current data model is bootstrapping an existing `option` since the `AutoGenerationOption` doesn’t have an identifier apart from it’s internal `id`(Database PK). This domain being an `OpenmrsObject`, I would except it to have a `uuid`, was this by design or we just missed out adding the `uuid` property to the [hibernate mapping](https://github.com/openmrs/openmrs-module-idgen/blob/master/api/src/main/resources/IdentifierSource.hbm.xml#L71-L78)?

I also found this:

> <https://github.com/openmrs/openmrs-module-idgen/blob/master/api/src/main/java/org/openmrs/module/idgen/AutoGenerationOption.java#L170-L172>

The above looks too hacky 🤭

My suggestion is adding full support of a `uuid` property like any other `OpenmrsObject` and maybe later, expanding the `Service` layer to retrieve instances by the property.

Thoughts?

/ cc: @mksd, @mogoodrich, @dkayiwa

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [March 16, 2020, 11:30am UTC](https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431/2 "2020-03-16T11:30:12Z")

</div>

The `uuid` field was not originally part of the data model. It was added in OpenMRS Core version 1.5

After which, modules followed the pattern of adding it. This looks like an obvious miss. Therefore, i vote YES to your suggestion. [https://tickets.openmrs.org/browse/TRUNK-2448](https://tickets.openmrs.org/browse/TRUNK-2448)

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [March 16, 2020, 12:42pm UTC](https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431/3 "2020-03-16T12:42:11Z")

</div>

Opened ticket at:

> <https://issues.openmrs.org/browse/IDGEN-114>

---

<div class="post-metadata">

**Author:** ![ibacher](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ibacher/32/19751_2.png) [@ibacher](https://talk.openmrs.org/u/ibacher)\
**Post date:** [March 16, 2020, 1:14pm UTC](https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431/4 "2020-03-16T13:14:36Z")

</div>

@samuel34 This is a good catch! We probably should also have a strategy to fill in UUIDs for existing `AutoGenerationOption` instances (the data model usually allows the UUID to be blank, even though, in practice, its usually set via Java code). I think I just got through telling someone not to worry about migrating UUIDs in Postgres, but there are examples where similar things have been done in the core liquibase files.

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [March 16, 2020, 1:50pm UTC](https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431/5 "2020-03-16T13:50:09Z")

</div>

Yes, agreed! AutoGenerationOption was probably created prior uuid’s existing, and we should add them in at this point.

And as @ibacher says when we made this change we should add a liquibase changeset (or other mechanism) to assign a UUID to any existing entries in the auto generation option table.

---

<div class="post-metadata">

**Author:** ![samuel34](https://talk.openmrs.org/user_avatar/talk.openmrs.org/samuel34/32/17813_2.png) [@samuel34](https://talk.openmrs.org/u/samuel34)\
**Post date:** [March 17, 2020, 12:52pm UTC](https://talk.openmrs.org/t/autogenerationoption-has-no-uuid/27431/6 "2020-03-17T12:52:01Z")

</div>

Opened Pull Request at:

> <https://github.com/openmrs/openmrs-module-idgen/pull/79>
