Migration problem

‘Soorten’ is data inserted by a csv file
The user has already many articles inserted

		'Artikel': collection ['post'] @small {
			'post': text @default: auto-increment || "01"
			'soort': text -> ^ ^ ^ .'Componenten'.'Soorten'[]
			'prijs': number 'euro' = >'soort'.'prijs'
        }

the customer wants also manual input, my solution is:

		'Artikel': collection ['post'] @small {
			'losse post': stategroup @default: 'nee' (
				'nee' {
					'soort': text -> ^ ^ ^ ^ .'Componenten'.'Soorten'[]
					'prijs': number 'euro' = >'soort'.'prijs'
				}
				'ja' {
					'soort': text ~> ^ ^ ^ ^ .'Componenten'.'Soorten'[]
					'prijs': number 'euro' //= >'soort'.'prijs'
				}
			)
			'prijs': number 'euro' = switch .'losse post' (
				|'ja' as $'p' => $'p'.'prijs'
				|'nee' as $'p' => $'p'.'prijs'
			)
        }

How can this be achieved without data loss?

So in the current version, all entries in Artikel link to an existing entry in Soorten? In that case, you should write a migration that sets the stategroup losse post to nee and copies the existing soort text value. Then after your migration, when the new version is running, users will be able to create new entries with losse post set to ja as well.

Something like this in your migration.alan:

'Artikel': collection = <! !> map ( $ .'Artikel'* ) as $ = (
  'losse post': stategroup = 'nee' (
    'soort': text = $ .'soort'
  )
)

Please note that we do not provide a value for prijs in the migration, since it is a derived (calculated) value.

Thanks, just wat the doctor ordered!