Migration introduce new struct field

Hey I am trying to add an instance of a struct, which looks like

struct PlanMeta {
    plan: Plan,
    appLimit: Number
};

where Plan is an enum. I have an instance called pocPlan. I am trying to populate it but am not sure what to put into the value of the “plan”. The type would be something like "/paas-$toVersion?/paas/Plan/Poc"

put("pocPlan") {
    createStruct(
        "/paas-$toVersion?/paas/PlanMeta",
        mapOf(
            "plan" to <whatGoesHere>,
            "appLimit" to 1
        )
    )
}

Can I reference this type with TypeRef somehow?
Thanks

not sure I understand your question.

you want to create a new enum value? (in a migration dsl script?)

here an example from our tests: https://github.com/NoumenaDigital/platform/blob/master/migration-dsl/src/test/kotlin/com/noumenadigital/platform/migration/dsl/UseCasesEnumTest.kt#L51

does that help?

Hi Ed,

For creating enums, there is the corresponding helper function

createEnum(
    "/paas-$toVersion?/paas/Plan",
    "POC"
)

I am not creating a new enum value. I am creating a var of a struct, where the first property of the struct is the enum.

like so
var pocPlan: PlanMeta = PlanMeta(plan = Plan.PoC, appLimit = 1);

Sounds about right

put("pocPlan") {
    createStruct(
        "/paas-$toVersion?/paas/PlanMeta",
        mapOf(
            "plan" to createEnum(
                "/paas-$toVersion?/paas/Plan",
                "POC"
            ),
            "appLimit" to NumberValue(1)
        )
    )
}

I believe that the appLimit has to be wrapped in a value creator too, I’ll check that one

ah ok gotcha, so that will be the enum instance in the value. cool ty

yes, here an example from our tests for creating new struct values

https://github.com/NoumenaDigital/platform/blob/master/migration-dsl/src/test/kotlin/com/noumenadigital/platform/migration/dsl/UseCasesStructTest.kt#L50

Yes got it. Thanks guys!