🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
ScriptAfterEvolve
Error creating thumbnail: File missing

A common scenario when evolving your model is that you need to do some data correction once the model has evolved. It may be to move data from an old place to a new place; it may be to initiate a valuestore or some setting.

This is easy to do manually with the OCL debugger—but doing so manually always poses a risk of forgetting or slipping up. This is especially true when you have multiple environments (devs, tests, acceptance, production, etc.).

To help with this, we introduce new functionality in the MDrivenServer supported by a model pattern.

New class: SysScriptAfterEvolveActionLog

with attributes:

  • ColumnNameKey:String
  • Expression:Text
  • Result:String
  • Performed:DateTime
  • Error:String

New ViewModel: SysScriptAfterEvolve, unrooted

In the SysScriptAfterEvolve viewmodel, add new action columns. Each action column will be checked after an Evolve in the MDrivenServer.

If the column name of the action is not present in SysScriptAfterEvolveActionLog.ColumnNameKey, the action is executed and a new SysScriptAfterEvolveActionLog is created, with your action column name set as ColumnNameKey.

This simple pattern ensures that your scripts after evolve are executed only once—but once in each environment where your model is deployed.

This pattern then helps you schedule and automate deploy since you no longer have to "do a few things once deployed" manually.

You can safely leave old action columns in SysScriptAfterEvolve since they will not run more than once in each database.

You can safely skip generations and evolve the current model since all actions not yet executed will execute and log in SysScriptAfterEvolveActionLog.