style(sql): make migrations more greppable

This commit is contained in:
Michael Gaffney committed 2022-08-08 18:17:57 -04:00
1 parent 02dd28f587
commit ac6f14a37f
77 files changed
+553 -1458

No files matched your search

@@ -24,9 +24,7 @@ where
-- migration 07_auth.up.sql This new definition also inserts the sub type's name
-- into the base type. The name column must be on the base type, so the database
-- can ensure that auth method names are unique across all sub types.
create or replace function
insert_auth_method_subtype()
returns trigger
create or replace function insert_auth_method_subtype() returns trigger
as $$
begin
insert into auth_method
@@ -44,9 +42,7 @@ comment on function insert_auth_method_subtype() is
-- that the name column is syncronized between the sub and base auth method
-- types. The name column must be on the base type, so the database can ensure
-- that auth method names are unique across all sub types.
create or replace function
update_auth_method_subtype()
returns trigger
create or replace function update_auth_method_subtype() returns trigger
as $$
begin
update auth_method set name = new.name where public_id = new.public_id and new.name != name;
@@ -56,23 +52,15 @@ $$ language plpgsql;
comment on function update_auth_method_subtype() is
'update_auth_method_subtype() will update base auth method type name column with new values from sub type';
create trigger
update_auth_method_subtype
before update on auth_oidc_method
create trigger update_auth_method_subtype before update on auth_oidc_method
for each row execute procedure update_auth_method_subtype();
create trigger
update_auth_method_subtype
before update on auth_password_method
create trigger update_auth_method_subtype before update on auth_password_method
for each row execute procedure update_auth_method_subtype();
-- delete_auth_method_subtype() is an after trigger function for subytypes of
-- auth_method
create or replace function
delete_auth_method_subtype()
returns trigger
create or replace function delete_auth_method_subtype() returns trigger
as $$
begin
delete from auth_method
@@ -83,15 +71,10 @@ $$ language plpgsql;
comment on function delete_auth_method_subtype is
'delete_auth_method_subtype() is an after trigger function for subytypes of auth_method';
create trigger
delete_auth_method_subtype
after delete on auth_oidc_method
create trigger delete_auth_method_subtype after delete on auth_oidc_method
for each row execute procedure delete_auth_method_subtype();
create trigger
delete_auth_method_subtype
after delete on auth_password_method
create trigger delete_auth_method_subtype after delete on auth_password_method
for each row execute procedure delete_auth_method_subtype();
commit;