🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
ScriptAfterEvolve
This page was created by Hans.karlsen on 2025-09-26. Last edited by Hans.karlsen on 2025-09-26.

ScriptAfterEvolve

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 old place to new place, it may be to initiate a valuestore or some setting.

This is easy to do manually with the OCL debugger - but manually always pose a risk for 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 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 SysScriptAfterEvolve since they will not run more than once in each database.

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