-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(rethinkdb): SuggestedAction: Phase 1 (#10035)
Signed-off-by: Matt Krick <[email protected]> Co-authored-by: Jordan Husney <[email protected]>
- Loading branch information
Showing
11 changed files
with
178 additions
and
58 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
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