-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add
team_integrations
table (#2499)
* feat: Add team_integrations table * feat: Add team_integrations table * chore: Update sync scripts
- Loading branch information
1 parent
d517f7d
commit 4be7446
Showing
7 changed files
with
138 additions
and
1 deletion.
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
1 change: 1 addition & 0 deletions
1
hasura.planx.uk/migrations/1701282718987_create_table_public_team_integrations/down.sql
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 @@ | ||
DROP TABLE "public"."team_integrations"; |
11 changes: 11 additions & 0 deletions
11
hasura.planx.uk/migrations/1701282718987_create_table_public_team_integrations/up.sql
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,11 @@ | ||
CREATE TABLE "public"."team_integrations" ( | ||
"id" serial NOT NULL, | ||
"team_id" integer NOT NULL, | ||
"staging_bops_submission_url" text, | ||
"production_bops_submission_url" text, | ||
PRIMARY KEY ("id"), | ||
FOREIGN KEY ("team_id") REFERENCES "public"."teams"("id") ON UPDATE restrict ON DELETE cascade, | ||
UNIQUE ("team_id") | ||
); | ||
|
||
COMMENT ON TABLE "public"."team_integrations" IS E'Tracks URLs and API keys for integrations'; |
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,76 @@ | ||
const { introspectAs } = require("./utils"); | ||
|
||
describe("team_integrations", () => { | ||
describe("public", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("public"); | ||
}); | ||
|
||
test("cannot query team_integrations", () => { | ||
expect(i.queries).not.toContain("team_integrations"); | ||
}); | ||
|
||
test("cannot create, update, or delete team_integrations", () => { | ||
expect(i).toHaveNoMutationsFor("team_integrations"); | ||
}); | ||
}); | ||
|
||
describe("admin", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("admin"); | ||
}); | ||
|
||
test("has full access to query and mutate team_integrations", () => { | ||
expect(i.queries).toContain("team_integrations"); | ||
expect(i.mutations).toContain("insert_team_integrations"); | ||
expect(i.mutations).toContain("update_team_integrations_by_pk"); | ||
expect(i.mutations).toContain("delete_team_integrations"); | ||
}); | ||
}); | ||
|
||
describe("platformAdmin", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("platformAdmin"); | ||
}); | ||
|
||
test("cannot query team_integrations", () => { | ||
expect(i.queries).not.toContain("team_integrations"); | ||
}); | ||
|
||
test("cannot create, update, or delete team_integrations", () => { | ||
expect(i).toHaveNoMutationsFor("team_integrations"); | ||
}); | ||
}); | ||
|
||
describe("teamEditor", () => { | ||
beforeAll(async () => { | ||
i = await introspectAs("teamEditor"); | ||
}); | ||
|
||
test("cannot query team_integrations", () => { | ||
expect(i.queries).not.toContain("team_integrations"); | ||
}); | ||
|
||
test("cannot create, update, or delete team_integrations", () => { | ||
expect(i).toHaveNoMutationsFor("team_integrations"); | ||
}); | ||
}); | ||
|
||
describe("api", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("api"); | ||
}); | ||
|
||
test("can query team_integrations", () => { | ||
expect(i.queries).toContain("team_integrations"); | ||
}); | ||
|
||
test("cannot create, update, or delete team_integrations", () => { | ||
expect(i).toHaveNoMutationsFor("team_integrations"); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-- insert team_integrations overwriting conflicts | ||
CREATE TEMPORARY TABLE sync_team_integrations ( | ||
id serial, | ||
team_id integer, | ||
staging_bops_submission_url text | ||
); | ||
|
||
\ COPY sync_team_integrations | ||
FROM | ||
'/tmp/team_integrations.csv' WITH (FORMAT csv, DELIMITER ';'); | ||
|
||
INSERT INTO | ||
team_integrations (id, team_id, staging_bops_submission_url) | ||
SELECT | ||
id, | ||
team_id, | ||
staging_bops_submission_url | ||
FROM | ||
sync_team_integrations ON CONFLICT (id) DO | ||
UPDATE | ||
SET | ||
team_id = EXCLUDED.team_id, | ||
staging_bops_submission_url = EXCLUDED.staging_bops_submission_url; |