# Package upgrade for data type

**URL:** <https://forum.canton.network/t/package-upgrade-for-data-type/6521>\
**Category:** App Development\
**Tags:** version, upgrade, canton\
**Created:** [May 9, 2023, 6:20pm UTC](https://forum.canton.network/t/package-upgrade-for-data-type/6521 "2023-05-09T18:20:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wilsonhsu0102](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/wilsonhsu0102/32/6122_2.png) [@wilsonhsu0102](https://forum.canton.network/u/wilsonhsu0102)\
**Post date:** [May 9, 2023, 6:20pm UTC](https://forum.canton.network/t/package-upgrade-for-data-type/6521/1 "2023-05-09T18:20:20Z")

</div>

Hi team,

I have a daml project/package specifically for Enums (no template object at all).  
Example:

```haskell
module Enums.PhoneType where

data PhoneType = MOBILE | BUSINESS | OTHER deriving (Eq, Show)

```

and as you can imaging for an Enum package, it is a data-dependency to many other daml project that we are building for our app.

I am starting to look into how to upgrade packages, but I only see examples for upgrading `template` type and not `data` type. Could you guide me on how to upgrade `data` type from `enum-0.0.1.dar` to `enum-0.0.2.dar`?

Another question is, in my other daml projects, I put `enum-0.0.1.dar` as a data-dependency:

```haskell
name: another-project
version: 0.0.1
data-dependencies:
  - .lib/enum-0.0.1.dar

```

If I want to use `enum-0.0.2.dar` in my `another-project`, does that mean I need to also upgrade the data-dependency in my `another-project` to:

```haskell
name: another-project
version: 0.0.2
data-dependencies:
  - .lib/enum-0.0.2.dar

```

Doesn’t this mean I need to traverse down the whole dependency tree and create a new dar version for every package impacted by the change?

Thank you so much in advance.

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [May 11, 2023, 1:17pm UTC](https://forum.canton.network/t/package-upgrade-for-data-type/6521/2 "2023-05-11T13:17:40Z")

</div>

Yes, you have to traverse the dependency chains and upgrade all templates/contracts that depend on the enum.

You can break up such dependency chains with Daml Interfaces.

---

<div class="post-metadata">

**Author:** ![wilsonhsu0102](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/wilsonhsu0102/32/6122_2.png) [@wilsonhsu0102](https://forum.canton.network/u/wilsonhsu0102)\
**Post date:** [May 11, 2023, 3:15pm UTC](https://forum.canton.network/t/package-upgrade-for-data-type/6521/3 "2023-05-11T15:15:56Z")

</div>

Thanks for the reply @bernhard.

So how do we upgrade the contracts that depend on the enum? Do we just change the version reference in `data-dependencies` for enum package and it will reference the upgraded enum package? and set the enum field to something else if the original one is removed from upgraded enum definition.

I am unsure, because there’s no actual “contract” for a enum type and I couldn’t find a doc that explains this part.

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [May 18, 2023, 1:49pm UTC](https://forum.canton.network/t/package-upgrade-for-data-type/6521/4 "2023-05-18T13:49:42Z")

</div>

Yes, that’s exactly right. The `data-dependencies` point to a file. Change that to the newly compiled enum package. Then follow compiler errors to refactor changed enum values.
