Hello all,
I want to ask what is the correct/best way to initialize documents in A12 application.
Currently, in our project, we use the mgmtp.a12.dataservices.initialization.scripts.jsonRpc.enabledmgmtp.a12.dataservices.initialization.scripts.jsonRpc.enabled with ADD_DOCUMENT operation as mention here. But it will add the documents every time the application is restart. So we add a flag isImported to the document. Check it together with the document business key in the DocumentPersister (2023.02) to make sure there are no duplicate documents imported.
However, I see the work here is too much for a simple task āinitialize data documentā and I would expect there is a way simpler and more convenient to do it.
I wonder if should we somehow use init-app in this case? But it will require DevOpt effort. And before start trying it, I would like to take the advice from all of you guys.
Thank a lot!
For this case you can use dataservices-server-init-app to setup all needed stuff before the server starts. See Initialization Sequence or Cluster-safe Configuration.
Hello @petr-high-peak,
Thank you for your answer.
From what I have experienced so far, I want to add additional informations and how I deal with it in my project.
dataservices-server-init-app is the correct place to set up initial document data. But still, you cannot use ADD_DOCUMENT script with mgmtp.a12.dataservices.initialization.scripts.jsonRpc.enabled because the init-app is used for migration data also so it is supposed to run more than one time. Which means, the init document data is still duplicated => This config should never work for init document data for PROD but only for TESTING
- Check duplicated documents using
DocumentPersister is a WORK-AROUND
Solution in my project:
Still use ADD_DOCUMENT scripts for initialize documents but we dont use the mgmtp.a12.dataservices.initialization.scripts.jsonRpc.enabled config but run them manually with @MigrationStep in init-app