Open
Description
Consider the following model:
UserGroup: {
fields: [
{name: 'name', type: 'string', unique: true, required: true},
{name: 'description', type: 'string'}
],
hasMany: [
{model: 'User', name: 'users'}
]
}
This will create a table like this:
CREATE TABLE USER_GROUP_USER (
USER_GROUP_ID BIGINT NOT NULL,
USER_ID BIGINT NOT NULL,
CONSTRAINT FK_USER_GROUP_USER FOREIGN KEY (USER_GROUP_ID) REFERENCES USER_GROUP(ID)
ON DELETE CASCADE ON UPDATE NO ACTION
);
There is no unique constraint for users in the user group table.
We should add support for a new "unique" keyword option to hasMany fields like this:
...
hasMany: [
{model: 'User', name: 'users', unique: true}
]
...
With the "unique" keyword we should create a unique index like this:
CREATE unique INDEX IDX_USER_GROUP_USER ON USER_GROUP_USER(USER_GROUP_ID, USER_ID);
Metadata
Metadata
Assignees
Labels
No labels