Create entity extends from User entity using cuba-cli

Hello everyone,
How can I create an entity (eg. ExtUser) that inherit from User entity using cuba-cli?
I’ve tried create an entity using create-entity command and edit the extends class to User, but it failed when run gradlew updateDb command.
Please help me, thank you!

Hi,
When the entity is created using CLI you should manually edit the generated SQL update-script. gradlew updateDb only executes the script.

For instance, in my project, it is modules\core\db\update\hsql\20\200212-1-createExtUser.sql
And I should add the following code there (for ‘single table’ inheritance strategy).

-- begin SEC_USER
alter table SEC_USER add column USER_ADD_INFO varchar(255) ^
alter table SEC_USER add column DTYPE varchar(100) ^
update SEC_USER set DTYPE = 'sec$User' where DTYPE is null ^
-- end SEC_USER

It works.

CUBA Studio has a tool to generate DB-scripts. It is available in Free version too.
So you can open the project in Studio, edit the entity and then execute CUBA -> Generate Database Scripts.
image

Correct update-script should appear. Save it and run gradlew updateDb or CUBA -> Update Database in Studio.
image

Regards.