-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(user): Migrate user module to DML #10389
Conversation
🦋 Changeset detectedLatest commit: 6212ab3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 65 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
5 Skipped Deployments
|
const expireDate = new Date().setMilliseconds( | ||
new Date().getMilliseconds() + 60 * 60 * 24 | ||
) | ||
|
||
const defaultInviteData = [ | ||
{ | ||
id: "1", | ||
email: "[email protected]", | ||
token: "test", | ||
expires_at: expireDate, | ||
}, | ||
{ | ||
id: "2", | ||
email: "[email protected]", | ||
token: "test", | ||
expires_at: expireDate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: The given value was overritten by the module so it was not doing anything
expires_at: new Date().setMilliseconds( | ||
new Date().getMilliseconds() + this.config.expiresIn * 1000 | ||
), | ||
expires_at: new Date(Date.now() + this.config.expiresIn * 1000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: this was giving a big int instead of a date, now it does the same thing but provide a date instead
const id = generateEntityId((invite as { id?: string }).id, "invite") | ||
return { | ||
...invite, | ||
expires_at: new Date(), | ||
token: "placeholder", | ||
id, | ||
expires_at: new Date(Date.now() + this.config.expiresIn * 1000), | ||
token: this.generateToken({ id, email: invite.email }), | ||
} | ||
}) | ||
|
||
const created = await this.inviteService_.create(toCreate, sharedContext) | ||
|
||
const updates = created.map((invite) => { | ||
return { | ||
id: invite.id, | ||
expires_at: new Date().setMilliseconds( | ||
new Date().getMilliseconds() + this.config.expiresIn * 1000 | ||
), | ||
token: this.generateToken({ id: invite.id, email: invite.email }), | ||
} | ||
}) | ||
|
||
return await this.inviteService_.update(updates, sharedContext) | ||
return await this.inviteService_.create(toCreate, sharedContext) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: This is a simplification, instead of doing a create and then an update, we only perform a create but the result remain unchanged
this.addSql('drop index if exists "IDX_invite_email";'); | ||
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_invite_email_unique" ON "invite" (email) WHERE deleted_at IS NULL;'); | ||
|
||
this.addSql('drop index if exists "IDX_user_email";'); | ||
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_user_email_unique" ON "user" (email) WHERE deleted_at IS NULL;'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: this apply the right name based on convention
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* feat(user): Migrate user module to DML * Create rotten-tigers-worry.md * update indexes names following conventions * remove duplicate modifier
RESOLVES FRMW-2817
What
Migrate user to DML