Skip to content

Commit 0903448

Browse files
committed
feat: add github_organization_members
1 parent 31cc528 commit 0903448

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @param { import("knex").Knex } knex
3+
* @returns { Promise<void> }
4+
*/
5+
exports.up = async (knex) => {
6+
await knex.schema.createTable("github_organization_members", (table) => {
7+
table.increments("id").primary(); // Primary key
8+
// Foreign key to 'github_organizations' table
9+
table
10+
.integer("github_organization_id")
11+
.notNullable()
12+
.unsigned()
13+
.references("id")
14+
.inTable("github_organizations")
15+
.onDelete("CASCADE") // Deletes repository if the organization is deleted
16+
.onUpdate("CASCADE"); // Updates repository if the organization ID is updated
17+
18+
// Foreign key to 'github_organizations' table
19+
table
20+
.integer("github_user_id")
21+
.notNullable()
22+
.unsigned()
23+
.references("id")
24+
.inTable("github_users")
25+
.onDelete("CASCADE") // Deletes repository if the organization is deleted
26+
.onUpdate("CASCADE"); // Updates repository if the organization ID is updated
27+
});
28+
};
29+
30+
/**
31+
* @param { import("knex").Knex } knex
32+
* @returns { Promise<void> }
33+
*/
34+
exports.down = async (knex) => {
35+
// Drop table
36+
await knex.schema.dropTableIfExists('github_organization_members')
37+
};

src/database/schema/schema.sql

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,37 @@ CREATE SEQUENCE public.compliance_checks_tasks_id_seq
301301
ALTER SEQUENCE public.compliance_checks_tasks_id_seq OWNED BY public.compliance_checks_tasks.id;
302302

303303

304+
--
305+
-- Name: github_organization_members; Type: TABLE; Schema: public; Owner: -
306+
--
307+
308+
CREATE TABLE public.github_organization_members (
309+
id integer NOT NULL,
310+
github_organization_id integer NOT NULL,
311+
github_user_id integer NOT NULL
312+
);
313+
314+
315+
--
316+
-- Name: github_organization_members_id_seq; Type: SEQUENCE; Schema: public; Owner: -
317+
--
318+
319+
CREATE SEQUENCE public.github_organization_members_id_seq
320+
AS integer
321+
START WITH 1
322+
INCREMENT BY 1
323+
NO MINVALUE
324+
NO MAXVALUE
325+
CACHE 1;
326+
327+
328+
--
329+
-- Name: github_organization_members_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
330+
--
331+
332+
ALTER SEQUENCE public.github_organization_members_id_seq OWNED BY public.github_organization_members.id;
333+
334+
304335
--
305336
-- Name: github_organizations; Type: TABLE; Schema: public; Owner: -
306337
--
@@ -931,6 +962,13 @@ ALTER TABLE ONLY public.compliance_checks_results ALTER COLUMN id SET DEFAULT ne
931962
ALTER TABLE ONLY public.compliance_checks_tasks ALTER COLUMN id SET DEFAULT nextval('public.compliance_checks_tasks_id_seq'::regclass);
932963

933964

965+
--
966+
-- Name: github_organization_members id; Type: DEFAULT; Schema: public; Owner: -
967+
--
968+
969+
ALTER TABLE ONLY public.github_organization_members ALTER COLUMN id SET DEFAULT nextval('public.github_organization_members_id_seq'::regclass);
970+
971+
934972
--
935973
-- Name: github_organizations id; Type: DEFAULT; Schema: public; Owner: -
936974
--
@@ -1065,6 +1103,14 @@ ALTER TABLE ONLY public.compliance_checks_tasks
10651103
ADD CONSTRAINT compliance_checks_tasks_pkey PRIMARY KEY (id);
10661104

10671105

1106+
--
1107+
-- Name: github_organization_members github_organization_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -
1108+
--
1109+
1110+
ALTER TABLE ONLY public.github_organization_members
1111+
ADD CONSTRAINT github_organization_members_pkey PRIMARY KEY (id);
1112+
1113+
10681114
--
10691115
-- Name: github_organizations github_organizations_github_org_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
10701116
--
@@ -1347,6 +1393,22 @@ ALTER TABLE ONLY public.compliance_checks_tasks
13471393
ADD CONSTRAINT compliance_checks_tasks_project_id_foreign FOREIGN KEY (project_id) REFERENCES public.projects(id) ON UPDATE CASCADE ON DELETE CASCADE;
13481394

13491395

1396+
--
1397+
-- Name: github_organization_members github_organization_members_github_organization_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
1398+
--
1399+
1400+
ALTER TABLE ONLY public.github_organization_members
1401+
ADD CONSTRAINT github_organization_members_github_organization_id_foreign FOREIGN KEY (github_organization_id) REFERENCES public.github_organizations(id) ON UPDATE CASCADE ON DELETE CASCADE;
1402+
1403+
1404+
--
1405+
-- Name: github_organization_members github_organization_members_github_user_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
1406+
--
1407+
1408+
ALTER TABLE ONLY public.github_organization_members
1409+
ADD CONSTRAINT github_organization_members_github_user_id_foreign FOREIGN KEY (github_user_id) REFERENCES public.github_users(id) ON UPDATE CASCADE ON DELETE CASCADE;
1410+
1411+
13501412
--
13511413
-- Name: github_organizations github_organizations_project_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: -
13521414
--

0 commit comments

Comments
 (0)