I'm working on a project needing custom constraints for row access and eventually custom filters, but I'm having some difficulties to understand the logic behind them being defined in the cuba application itself instead in cuba studio (especially the constraints). As a developer, I need to define the constraints during the development process, and then being able to deploy the app with constraints built-in someway. What is the best way to achieve this? I can now see only two possibilities:
manually copying the sql for the appropriate table in the INIT DATA
manually exporting the table and importing it in the deployed application
Since what you want to be built in into your application is database content, you somehow have to get the data into the database of the deployed application.
As you said, you can use the 30.create-db.sql file for that. Another approach would be to use the generic export and import feature of entity instances as JSON. These zip files can be imported after the application started manually, or you can create some facility to do this at application start time. Here you can find more details on the different possibilities: https://www.road-to-cuba-and-beyond.com/test-and-seed-data/
In the github project around testdata, i created a JsonDataImporter that will pick up the JSON files you extracted from the entities inspector and load them.