Problem with migration

After first have migrated from empty (no problem)
The migration from release gave the following error:

uccessfully created /home/coder/project/dist/project.pkg
/home/coder/project/migrations/from_release/migration.alan:4:33 to 4:34 error: unexpected keyword `?` while making a decision for stategroup 'select' of !'variable selector'.'stack'?'non-empty'. Options:
	- a key literal             for state 'branch'
	- keyword `.`               for state 'this'
	- keyword `>`               for state 'this'
	- keyword `^`               for state 'this'

the migration.alan file below shows an underscore under the question mark ? before ‘Type’

	'Users': collection = <!"Default collection mapping, should succeed when key-property remains the same."!> map ( $ .'Users' ) as $ = (
		'Naam': text = $ .'Naam'
		'Type': stategroup = switch $ ?'Type' (
			|'Admin' as $ = 'Admin' ( )
			|'User' as $ = 'User' ( )
		)
	)
	'Passwords': collection = <!"Default collection mapping, should succeed when key-property remains the same."!> map ( $ .'Passwords' ) as $ = (
		'User': text = $ .'User'
		'Data': group = $ +'Data' as $ (
			'Password': text = $ .'Password'
			'Active': stategroup = switch $ ?'Active' (
				|'No' as $ = 'No' ( )
				|'Yes' as $ = 'Yes' ( )
			)
		)
	)

after several migration attempts from empty and from release the error remains.
what is going wrong?

Can you delete/rename your ‘from_release’ migration directory so that a new one will be generated?

There have been changes in the migration language syntax in version 97 and I think you still have a migration.alan file that uses the old syntax, which causes this error message.

after deleted following message:

Successfully created /home/coder/project/dist/project.pkg
/home/coder/project/migrations/from_release error: unable to follow path step, directory misses entry:
	migration.alan
migrations/from_release notice: 1 errors

after renamed following message:

uccessfully created /home/coder/project/dist/project.pkg
/home/coder/project/migrations/from_release error: unable to follow path step, directory misses entry:
	migration.alan
/home/coder/project/migrations/from_release error: superfluous entry in a static directory:
	migrations.alan
migrations/from_release notice: 2 errors

after migration emptied except ‘root’:

Successfully created /home/coder/project/dist/project.pkg
/home/coder/project/migrations/from_release/migration.alan:1:19 to 1:19 error: missing entry `Users` in 'properties'
/home/coder/project/migrations/from_release/migration.alan:1:19 to 1:19 error: missing entry `Passwords` in 'properties'
/home/coder/project/migrations/from_release/migration.alan:1:19 to 1:19 error: missing entry `Presets` in 'properties'
/home/coder/project/migrations/from_release/migration.alan:1:19 to 1:19 error: missing entry `Componenten` in 'properties'
/home/coder/project/migrations/from_release/migration.alan:1:19 to 1:19 error: missing entry `Calculatie` in 'properties'
		defined by .<root> of type 'application'!'node'
	 at /home/coder/project/models/model/application.alan:25:2 to 786:51
/home/coder/project/migrations/from_release/migration.alan notice: 5 semantic errors, with 0 unknown

Is this still an issue and if so, can you share the name of your IDE account with me in a private message?

This has already been resolved, but I will share some of the details which might be useful to other people with the same question.

The migrations/from_release directory will not be overwritten once it already exists.

In this case, the migration language syntax was changed after a project upgrade. We have resolved it by running ‘Alan: Generate Migration’ from the Command Palette in the online IDE.

More information about migrations can be found on Application data migration - Alan Application Platform

1 Like

Hi, I am facing a similar issue.
After initializing with the empty dataset, I then went ahead to populate the application with data.
I have made changes to the application model (adding some extra fields).
I now want to migrate to the new model. I have followed the steps here https://alan-platform.com/pages/tutorials/migrations/2022.2/migrations.html

I am getting an error coming from the from_release/migration.alan file.
And basically the error indicates that they’re from the new fields I added to the application model.

I assume your migration contains a line like this:

'Longitude': text = $ .'Longitude'

The left hand side points to a property in the target model.
The right hand side points to a property in the source model.

When a property does not exist in the source model, you will have to provide a value yourself during the first migration where this property is introduced.

In your case, this should work:

'Longitude': text = ""

(setting the Longitude to an empty string)

You can find more details in https://alan-platform.com/pages/tutorials/migrations/2022.2/migrations.html#migration-maintenance

Great! this worked for properties that I introduced that had text attribute.

In the case of “file”, “stategroup” and “date and time” (new fields I introduced) does it work the same way.

This is an example for a file attribute

The syntax is different for different property types.

You can find more information about this on https://alan-platform.com/pages/docs/datastore/99.1/migration_mapping/grammar.html#grammar-rule–node-mapping

In the case of a file, it should be:

'Receipt': file = [ "" , "" ]

…although this is a bit unusual, because this way you are not referring to an existing file. We recommend to use a stategroup which has states for ‘file available’ and ‘file not available’, so you can initialize this to ‘file not available’ in your migration.

1 Like