Skip to content
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: Add migration for shared secret integration provider #10382

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 TYPE "IntegrationProviderAuthStrategyEnum" ADD VALUE IF NOT EXISTS 'sharedSecret';
ALTER TABLE "IntegrationProvider"
ADD COLUMN IF NOT EXISTS "sharedSecret" VARCHAR(255);

ALTER TABLE "TeamMemberIntegrationAuth"
ADD COLUMN IF NOT EXISTS "channel" VARCHAR(255);
END $$;
`)
await client.end()
}

export async function down() {
const client = new Client(getPgConfig())
await client.connect()
await client.query(`
DO $$
BEGIN
DELETE FROM "IntegrationProvider" WHERE "authStrategy" = 'sharedSecret';
ALTER TYPE "IntegrationProviderAuthStrategyEnum" RENAME TO "IntegrationProviderAuthStrategyEnumA_delete";

CREATE TYPE "IntegrationProviderAuthStrategyEnum" AS ENUM (
'pat',
'oauth2',
'webhook',
'oauth1'
);

ALTER TABLE "IntegrationProvider"
DROP COLUMN IF EXISTS "sharedSecret",
ALTER COLUMN "authStrategy" TYPE "IntegrationProviderAuthStrategyEnum" USING "authStrategy"::text::"IntegrationProviderAuthStrategyEnum";

DROP TYPE "IntegrationProviderAuthStrategyEnumA_delete";

ALTER TABLE "TeamMemberIntegrationAuth"
DROP COLUMN IF EXISTS "channel";
END $$;
`)
await client.end()
}