-
Notifications
You must be signed in to change notification settings - Fork 336
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
chore(rethinkdb): SuggestedAction: Phase 1 #10035
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
98755f9
chore: migrate EmailVerification to pg
jordanh 6fd49d8
Merge branch 'master' into chore/9491/migrate-emailverification
mattkrick d171d43
fix: migrate all the rows
mattkrick d30454c
fix migration on empty db
mattkrick 1220d10
write to PG
mattkrick c7fb5da
fix tsc errors
mattkrick 189585e
Merge branch 'master' into chore/SuggestedAction-phase1
mattkrick 7cc36db
fixup: tests for SA
mattkrick d324a53
Merge branch 'master' into chore/SuggestedAction-phase1
mattkrick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
52 changes: 52 additions & 0 deletions
52
packages/server/postgres/migrations/1721940319404_SuggestedAction-phase1.ts
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,52 @@ | ||
import {Client} from 'pg' | ||
import getPgConfig from '../getPgConfig' | ||
|
||
export async function up() { | ||
const client = new Client(getPgConfig()) | ||
await client.connect() | ||
await client.query(` | ||
DO $$ | ||
BEGIN | ||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'SuggestedActionTypeEnum') THEN | ||
CREATE TYPE "SuggestedActionTypeEnum" AS ENUM ( | ||
'inviteYourTeam', | ||
'tryTheDemo', | ||
'createNewTeam', | ||
'tryRetroMeeting', | ||
'tryActionMeeting' | ||
); | ||
END IF; | ||
CREATE TABLE IF NOT EXISTS "SuggestedAction" ( | ||
"id" VARCHAR(100) PRIMARY KEY, | ||
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
"priority" SMALLINT NOT NULL DEFAULT 0, | ||
"removedAt" TIMESTAMP WITH TIME ZONE, | ||
"type" "SuggestedActionTypeEnum" NOT NULL, | ||
"teamId" VARCHAR(100), | ||
"userId" VARCHAR(100) NOT NULL, | ||
UNIQUE("userId", "type"), | ||
CONSTRAINT "fk_userId" | ||
FOREIGN KEY("userId") | ||
REFERENCES "User"("id") | ||
ON DELETE CASCADE, | ||
CONSTRAINT "fk_teamId" | ||
FOREIGN KEY("teamId") | ||
REFERENCES "Team"("id") | ||
ON DELETE CASCADE | ||
); | ||
CREATE INDEX IF NOT EXISTS "idx_SuggestedAction_teamId" ON "SuggestedAction"("teamId"); | ||
CREATE INDEX IF NOT EXISTS "idx_SuggestedAction_userId" ON "SuggestedAction"("userId"); | ||
END $$; | ||
`) | ||
await client.end() | ||
} | ||
|
||
export async function down() { | ||
const client = new Client(getPgConfig()) | ||
await client.connect() | ||
await client.query(` | ||
DROP TABLE "SuggestedAction"; | ||
DROP TYPE "SuggestedActionTypeEnum"; | ||
` /* Do undo magic */) | ||
await client.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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ensure the logic for checking existing suggested actions is correct.
The logic correctly checks for existing suggested actions and inserts a new one if none exist. However, consider using the same database (PostgreSQL) for consistency instead of mixing RethinkDB and PostgreSQL.
Committable suggestion