Projectname table prefix mandatory?

2017-12-17 20_15_40-proyecto-ejemplo - CUBA Studio

It’s mandatory to have the project name as table prefix?
I don’t like to much to have the name of the project as prefix in all the tables and IMHO is unnecesary.


Hi @giuseppe

The prefix enables to decide if we should drop the table when the corresponding entity is removed from the project. But you are right, it should not be mandatory for tracking changes and updating the table. So I’ve created an issue to fix it in the future.

At the moment you can get rid of prefix but keep the ability to track changes and generate updates for the table if you add the DesignSupport annotation to the entity:

@Table(name = "mytable")
@Entity(name = "sample$MyEntity")
public class MyEntity extends ... {

It will make Studio think that this entity was imported from a legacy database, and in this case it tracks the table if it is in the main data store.

Thanks Konstantin.

If this issue goes further, if we modify the entity maybe change will apply to database too?
I ask this because maybe I can live using project prefix instead to add @DesignSupport in all my entities, and change it later if is not a pain.

Studio cannot rename tables, so if you rename the table for an entity in Studio, it will generate update scripts for dropping the old table and creating new one.

So this approach will work if you can afford to lose all data and recreate the database from scratch. Otherwise you will have to rename the tables manually in a database-specific way.

but associations and so on will still working right?

Database will not enter into production until some months,then, data is only for testing purposes.

but associations and so on will still working right?

Of course, if you recreate database from scratch, it will contain all foreign keys - they will be created from the data model together with tables.

1 Like