-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matt Krick <matt.krick@gmail.com>
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/server/postgres/migrations/1722632147643_IntegrationProvider-null-not-distinct.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,32 @@ | ||
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 | ||
ALTER TABLE "IntegrationProvider" | ||
DROP CONSTRAINT "unique_per_team_and_org"; | ||
ALTER TABLE "IntegrationProvider" | ||
ADD CONSTRAINT "unique_per_team_and_org" UNIQUE NULLS NOT DISTINCT ("orgId", "teamId", "service", "authStrategy"); | ||
END $$; | ||
`) | ||
await client.end() | ||
} | ||
|
||
export async function down() { | ||
const client = new Client(getPgConfig()) | ||
await client.connect() | ||
await client.query(` | ||
DO $$ | ||
BEGIN | ||
ALTER TABLE "IntegrationProvider" | ||
DROP CONSTRAINT "unique_per_team_and_org"; | ||
ALTER TABLE "IntegrationProvider" | ||
ADD CONSTRAINT "unique_per_team_and_org" UNIQUE ("orgId", "teamId", "service", "authStrategy"); | ||
END $$; | ||
`) | ||
await client.end() | ||
} |