Is it possible to generate the sql script from the entity model

If I make any mistake and delete an SQL script that I ran already, is that possible to regenerate it automatically?

As I understood this question about the DB update script.
The update script is generated as a difference between database tables and entities in the data model.
You can generate the update script again if you connect the project and CUBA-Studio to an old copy of the database (before the upgrade). But you need to be sure that this is exactly the previous version of the database.

Of course, it is better to store scripts in Git.

1 Like

Hi,
If you don’t have valuable data in the database, then you can run “Create database”. It will re-create the database objects from scratch. Then invoke “Generate database scripts”, and you will get new scripts that bring the DB schema to the state corresponding to the data model.

1 Like