Skip to content

Commit

Permalink
fix: null not distinct (#10067)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <matt.krick@gmail.com>
  • Loading branch information
mattkrick authored Aug 2, 2024
1 parent 6819e90 commit e6204a7
Showing 1 changed file with 32 additions and 0 deletions.
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()
}

0 comments on commit e6204a7

Please sign in to comment.