The users and users_roles tables are duplicated, and the same happends to the roles.user_id column. We must implement one of the following solutions:
Throw an error when this happen.
Add an incremental suffix to the generated tables and columns
For example, if the Role entity has an explicit user_id column, the column produced by the Role -> User relationship must be named user_id2 or something similar.
The same applies to the corresponding table of the Users entity. As users table already exists (because the User entity is declared before Users), then the table must be named users2.
Also, we could return a result with warnings in those cases, as those scenarios are likely to be errors.
There are several scenarios where generated code (SQL, TS or Java) can produce several tables, columns or classes with the same name.
For example, if you define the following ER model:
The following SQL code is produced for SQLite:
The
users
andusers_roles
tables are duplicated, and the same happends to theroles.user_id
column. We must implement one of the following solutions:Role
entity has an explicituser_id
column, the column produced by theRole -> User
relationship must be nameduser_id2
or something similar.Users
entity. Asusers
table already exists (because theUser
entity is declared beforeUsers
), then the table must be namedusers2
.