Skip to content
Discussions/App Development/Package upgrade for data typeForum ↗

Package upgrade for data type

App Development4 posts254 viewsLast activity May 2023
WI
wilsonhsu0102OP
May 2023

Hi team,

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

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:

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:

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.

BE
bernhard
May 2023

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.

WI
wilsonhsu0102
May 2023

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.

BE
bernhard
May 2023

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.

← Back to Discussions