diff --git a/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.cockroach.up.sql b/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.cockroach.up.sql index d15c1305179..e1546033671 100644 --- a/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.cockroach.up.sql +++ b/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.cockroach.up.sql @@ -1,10 +1,10 @@ -- Migration generated by the command below; DO NOT EDIT. -- hydra:generate hydra migrate gen -CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON public.hydra_oauth2_flow USING btree (client_id, subject); -CREATE INDEX hydra_oauth2_flow_cid_idx ON public.hydra_oauth2_flow USING btree (client_id); -CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON public.hydra_oauth2_flow USING btree (login_session_id); -CREATE INDEX hydra_oauth2_flow_sub_idx ON public.hydra_oauth2_flow USING btree (subject); -CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON public.hydra_oauth2_flow USING btree (consent_challenge_id); -CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON public.hydra_oauth2_flow USING btree (login_verifier); -CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON public.hydra_oauth2_flow USING btree (consent_verifier); +CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON hydra_oauth2_flow USING btree (client_id, subject); +CREATE INDEX hydra_oauth2_flow_cid_idx ON hydra_oauth2_flow USING btree (client_id); +CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON hydra_oauth2_flow USING btree (login_session_id); +CREATE INDEX hydra_oauth2_flow_sub_idx ON hydra_oauth2_flow USING btree (subject); +CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON hydra_oauth2_flow USING btree (consent_challenge_id); +CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON hydra_oauth2_flow USING btree (login_verifier); +CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON hydra_oauth2_flow USING btree (consent_verifier); diff --git a/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.postgres.up.sql b/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.postgres.up.sql index b6072947990..b5a78f42d00 100644 --- a/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.postgres.up.sql +++ b/persistence/sql/migrations/20211019000001000002_merge_authentication_request_tables.postgres.up.sql @@ -1,30 +1,30 @@ -- Migration generated by the command below; DO NOT EDIT. -- hydra:generate hydra migrate gen -CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON public.hydra_oauth2_flow USING btree (client_id, subject); -CREATE INDEX hydra_oauth2_flow_cid_idx ON public.hydra_oauth2_flow USING btree (client_id); -CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON public.hydra_oauth2_flow USING btree (login_session_id); -CREATE INDEX hydra_oauth2_flow_sub_idx ON public.hydra_oauth2_flow USING btree (subject); -CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON public.hydra_oauth2_flow USING btree (consent_challenge_id); -CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON public.hydra_oauth2_flow USING btree (login_verifier); -CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON public.hydra_oauth2_flow USING btree (consent_verifier); +CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON hydra_oauth2_flow USING btree (client_id, subject); +CREATE INDEX hydra_oauth2_flow_cid_idx ON hydra_oauth2_flow USING btree (client_id); +CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON hydra_oauth2_flow USING btree (login_session_id); +CREATE INDEX hydra_oauth2_flow_sub_idx ON hydra_oauth2_flow USING btree (subject); +CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON hydra_oauth2_flow USING btree (consent_challenge_id); +CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON hydra_oauth2_flow USING btree (login_verifier); +CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON hydra_oauth2_flow USING btree (consent_verifier); -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES public.hydra_client(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES public.hydra_oauth2_authentication_session(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES hydra_client(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES hydra_oauth2_authentication_session(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; diff --git a/persistence/sql/migrations/20211019000001000003_merge_authentication_request_tables.cockroach.up.sql b/persistence/sql/migrations/20211019000001000003_merge_authentication_request_tables.cockroach.up.sql index cc70153c004..7360199eaf0 100644 --- a/persistence/sql/migrations/20211019000001000003_merge_authentication_request_tables.cockroach.up.sql +++ b/persistence/sql/migrations/20211019000001000003_merge_authentication_request_tables.cockroach.up.sql @@ -1,4 +1,4 @@ -- Migration generated by the command below; DO NOT EDIT. -- hydra:generate hydra migrate gen -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); diff --git a/persistence/sql/migrations/20211019000001000004_merge_authentication_request_tables.cockroach.up.sql b/persistence/sql/migrations/20211019000001000004_merge_authentication_request_tables.cockroach.up.sql index 43a05c95166..e2ceb8005af 100644 --- a/persistence/sql/migrations/20211019000001000004_merge_authentication_request_tables.cockroach.up.sql +++ b/persistence/sql/migrations/20211019000001000004_merge_authentication_request_tables.cockroach.up.sql @@ -1,21 +1,21 @@ -- Migration generated by the command below; DO NOT EDIT. -- hydra:generate hydra migrate gen -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES public.hydra_client(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES public.hydra_oauth2_authentication_session(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES hydra_client(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES hydra_oauth2_authentication_session(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; diff --git a/persistence/sql/migrations/20221109000010000000_fix_foreign_key.postgres.up.sql b/persistence/sql/migrations/20221109000010000000_fix_foreign_key.postgres.up.sql index 02ba8a741d5..2aa1368e628 100644 --- a/persistence/sql/migrations/20221109000010000000_fix_foreign_key.postgres.up.sql +++ b/persistence/sql/migrations/20221109000010000000_fix_foreign_key.postgres.up.sql @@ -1,3 +1,3 @@ ALTER TABLE hydra_oauth2_flow DROP CONSTRAINT hydra_oauth2_flow_login_session_id_fk; -ALTER TABLE hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES public.hydra_oauth2_authentication_session(id) ON DELETE SET NULL; +ALTER TABLE hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES hydra_oauth2_authentication_session(id) ON DELETE SET NULL; ALTER TABLE hydra_oauth2_flow ALTER COLUMN login_session_id DROP DEFAULT; diff --git a/persistence/sql/migrations/20221109000010000001_fix_foreign_key.cockroach.up.sql b/persistence/sql/migrations/20221109000010000001_fix_foreign_key.cockroach.up.sql index 7508696a8e6..a98521e4c6b 100644 --- a/persistence/sql/migrations/20221109000010000001_fix_foreign_key.cockroach.up.sql +++ b/persistence/sql/migrations/20221109000010000001_fix_foreign_key.cockroach.up.sql @@ -1,2 +1,2 @@ -ALTER TABLE hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES public.hydra_oauth2_authentication_session(id) ON DELETE SET NULL; +ALTER TABLE hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES hydra_oauth2_authentication_session(id) ON DELETE SET NULL; ALTER TABLE hydra_oauth2_flow ALTER COLUMN login_session_id DROP DEFAULT; diff --git a/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.cockroach.up.sql b/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.cockroach.up.sql index 3334a36d433..65bfc88776f 100644 --- a/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.cockroach.up.sql +++ b/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.cockroach.up.sql @@ -214,33 +214,33 @@ LEFT JOIN hydra_oauth2_consent_request_handled ON hydra_oauth2_consent_request.challenge = hydra_oauth2_consent_request_handled.challenge; --split -CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON public.hydra_oauth2_flow USING btree (client_id, subject); -CREATE INDEX hydra_oauth2_flow_cid_idx ON public.hydra_oauth2_flow USING btree (client_id); -CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON public.hydra_oauth2_flow USING btree (login_session_id); -CREATE INDEX hydra_oauth2_flow_sub_idx ON public.hydra_oauth2_flow USING btree (subject); -CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON public.hydra_oauth2_flow USING btree (consent_challenge_id); -CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON public.hydra_oauth2_flow USING btree (login_verifier); -CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON public.hydra_oauth2_flow USING btree (consent_verifier); +CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON hydra_oauth2_flow USING btree (client_id, subject); +CREATE INDEX hydra_oauth2_flow_cid_idx ON hydra_oauth2_flow USING btree (client_id); +CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON hydra_oauth2_flow USING btree (login_session_id); +CREATE INDEX hydra_oauth2_flow_sub_idx ON hydra_oauth2_flow USING btree (subject); +CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON hydra_oauth2_flow USING btree (consent_challenge_id); +CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON hydra_oauth2_flow USING btree (login_verifier); +CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON hydra_oauth2_flow USING btree (consent_verifier); --split -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); --split -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES public.hydra_client(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES public.hydra_oauth2_authentication_session(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES hydra_client(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES hydra_oauth2_authentication_session(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; --split DROP TABLE hydra_oauth2_consent_request_handled; diff --git a/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.postgres.up.sql b/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.postgres.up.sql index ed408191906..705483dce50 100644 --- a/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.postgres.up.sql +++ b/persistence/sql/src/20211019000001_merge_authentication_request_tables/20211019000001000000_merge_authentication_request_tables.postgres.up.sql @@ -214,32 +214,32 @@ LEFT JOIN hydra_oauth2_consent_request_handled ON hydra_oauth2_consent_request.challenge = hydra_oauth2_consent_request_handled.challenge; --split -CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON public.hydra_oauth2_flow USING btree (client_id, subject); -CREATE INDEX hydra_oauth2_flow_cid_idx ON public.hydra_oauth2_flow USING btree (client_id); -CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON public.hydra_oauth2_flow USING btree (login_session_id); -CREATE INDEX hydra_oauth2_flow_sub_idx ON public.hydra_oauth2_flow USING btree (subject); -CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON public.hydra_oauth2_flow USING btree (consent_challenge_id); -CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON public.hydra_oauth2_flow USING btree (login_verifier); -CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON public.hydra_oauth2_flow USING btree (consent_verifier); +CREATE INDEX hydra_oauth2_flow_client_id_subject_idx ON hydra_oauth2_flow USING btree (client_id, subject); +CREATE INDEX hydra_oauth2_flow_cid_idx ON hydra_oauth2_flow USING btree (client_id); +CREATE INDEX hydra_oauth2_flow_login_session_id_idx ON hydra_oauth2_flow USING btree (login_session_id); +CREATE INDEX hydra_oauth2_flow_sub_idx ON hydra_oauth2_flow USING btree (subject); +CREATE UNIQUE INDEX hydra_oauth2_flow_consent_challenge_idx ON hydra_oauth2_flow USING btree (consent_challenge_id); +CREATE UNIQUE INDEX hydra_oauth2_flow_login_verifier_idx ON hydra_oauth2_flow USING btree (login_verifier); +CREATE INDEX hydra_oauth2_flow_consent_verifier_idx ON hydra_oauth2_flow USING btree (consent_verifier); -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES public.hydra_client(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES public.hydra_oauth2_authentication_session(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_pkey PRIMARY KEY (login_challenge); +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_client_id_fk FOREIGN KEY (client_id) REFERENCES hydra_client(id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_flow ADD CONSTRAINT hydra_oauth2_flow_login_session_id_fk FOREIGN KEY (login_session_id) REFERENCES hydra_oauth2_authentication_session(id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_access DROP CONSTRAINT hydra_oauth2_access_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_access ADD CONSTRAINT hydra_oauth2_access_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_code DROP CONSTRAINT hydra_oauth2_code_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_code ADD CONSTRAINT hydra_oauth2_code_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_oidc DROP CONSTRAINT hydra_oauth2_oidc_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_oidc ADD CONSTRAINT hydra_oauth2_oidc_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_pkce DROP CONSTRAINT hydra_oauth2_pkce_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_pkce ADD CONSTRAINT hydra_oauth2_pkce_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; -ALTER TABLE ONLY public.hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; -ALTER TABLE ONLY public.hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES public.hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; +ALTER TABLE ONLY hydra_oauth2_refresh DROP CONSTRAINT hydra_oauth2_refresh_challenge_id_fk; +ALTER TABLE ONLY hydra_oauth2_refresh ADD CONSTRAINT hydra_oauth2_refresh_challenge_id_fk FOREIGN KEY (challenge_id) REFERENCES hydra_oauth2_flow(consent_challenge_id) ON DELETE CASCADE; --split DROP TABLE hydra_oauth2_consent_request_handled;