-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from codex-team/feat/note-settings-invitation…
…-hash Feat: invitation hash
- Loading branch information
Showing
9 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- Create "invitation hash" column in note_settings table | ||
DO $$ | ||
BEGIN | ||
IF NOT EXISTS(SELECT * | ||
FROM information_schema.columns | ||
WHERE table_name='note_settings' and column_name='invitation_hash') | ||
THEN | ||
ALTER TABLE "public"."note_settings" ADD COLUMN "invitation_hash" VARCHAR(255); | ||
END IF; | ||
END $$; | ||
|
||
-- Generate invitation hash for records with NULL invitation_hash | ||
DO $$ | ||
BEGIN | ||
UPDATE "public"."note_settings" | ||
SET "invitation_hash" = SUBSTRING(CAST(GEN_RANDOM_UUID() AS VARCHAR), 1, 10) | ||
WHERE "invitation_hash" IS NULL; | ||
END $$; | ||
|
||
-- Makes the column 'invitation_hash' NOT NULL | ||
DO $$ | ||
BEGIN | ||
ALTER TABLE "public"."note_settings" ALTER COLUMN "invitation_hash" SET NOT NULL; | ||
END $$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { nanoid } from 'nanoid'; | ||
|
||
/** | ||
* Create invitation hash | ||
* Used to invite users to team | ||
* | ||
* @param length - length of invitation hash | ||
*/ | ||
export function createInvitationHash(length: number = 10): string { | ||
return nanoid(length); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters