2022-10-11 16:59:52 -07:00
|
|
|
-- Copyright (c) HashiCorp, Inc.
|
2023-02-02 17:15:17 -08:00
|
|
|
-- SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
2022-10-11 16:59:52 -07:00
|
|
|
begin;
|
|
|
|
|
|
|
|
|
|
-- This deletes the base type if the concrete types exist anymore.
|
|
|
|
|
delete from auth_account
|
|
|
|
|
where public_id not in
|
|
|
|
|
(select public_id
|
|
|
|
|
from auth_oidc_account)
|
|
|
|
|
and public_id not in
|
|
|
|
|
(select public_id
|
|
|
|
|
from auth_password_account);
|
|
|
|
|
|
|
|
|
|
-- delete_auth_account_subtype() is an after trigger function for subytypes of
|
|
|
|
|
-- auth_account.
|
|
|
|
|
-- this function is similar to the delete_auth_method_subtype account created
|
|
|
|
|
-- in 2/10_auth.up.sql
|
|
|
|
|
create function delete_auth_account_subtype() returns trigger
|
|
|
|
|
as $$
|
|
|
|
|
begin
|
|
|
|
|
delete from auth_account
|
|
|
|
|
where public_id = old.public_id;
|
|
|
|
|
return null; -- results are ignore since this is an after trigger.
|
|
|
|
|
end;
|
|
|
|
|
$$ language plpgsql;
|
|
|
|
|
comment on function delete_auth_account_subtype is
|
2022-11-15 10:26:26 -08:00
|
|
|
'delete_auth_account_subtype() is an after trigger function for subytypes of auth_account';
|
2022-10-11 16:59:52 -07:00
|
|
|
|
|
|
|
|
create trigger delete_auth_account_subtype after delete on auth_oidc_account
|
|
|
|
|
for each row execute procedure delete_auth_account_subtype();
|
|
|
|
|
|
|
|
|
|
create trigger delete_auth_account_subtype after delete on auth_password_account
|
|
|
|
|
for each row execute procedure delete_auth_account_subtype();
|
|
|
|
|
|
|
|
|
|
commit;
|