Update DB Scripts in Cuba-CLI

Hi community,

I try to update this mysql script:
20.create-db.sql

in CUBA-CLI, does anybody have an idea, how to write it exactly?

Because if I try this, I get an error in CLI:

cuba>updateScript
? Script name (updateSomeTable) > 20.create-db.sql 
Script name may contain only letters, digits, dashes and underscores.

Thanks a lot

What are you trying to achieve exactly?

Because if you want to add YOUR custom constraints (beside the ones generated by the tools), the standard way of doing this is creating new file(s) next to the standard ones (10, 20, and 30) and numbering them like 21 to 29 (for example 21.create-db.sql).

So for example you could have the following files in the mysql directory:
10.create-db.sql
11.create-db.sql
20.create-db.sql
21.create-db.sql
30.create-db.sql

The bold ones are generated by the tools, and you should never edit them directly, but the others are under your complete control… Write whatever DML instructions you need (in standard SQL).

P.

PS: obviously they are executed in order when performing the first database initialisation, and I forgot to mention that this is all documented in the docs :wink:

Hi!

First of all, updateScript command doesn’t do what you think. It creates empty sql script with specially generated date prefix.

cuba>update-script
? Script name (updateSomeTable) > updateSomeEntityAttribute
	created  modules/core/db/update/hsql/18/180917-1-updateSomeEntityAttribute.sql

Secondly, CLI doesn’t write any scripts for you now (and maybe won’t). So if you wan’t to make some changes in them, do it by your hands.

You can see command description using --help flag.

cuba>update-script --help
Creates new database update script
Usage: update-script