Skip to content

Commit

Permalink
Add public.delete_vessel_fn, delete all data received from a vessel
Browse files Browse the repository at this point in the history
  • Loading branch information
xbgmsharp committed Oct 4, 2023
1 parent 9c7301d commit 53b25e1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions initdb/02_3_2_signalk_public_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1434,3 +1434,17 @@ BEGIN
select * from auth.accounts a where email = _email;
END
$dump_account$ language plpgsql security definer;

CREATE OR REPLACE FUNCTION public.delete_vessel_fn(IN _vessel_id TEXT) RETURNS BOOLEAN
AS $delete_account$
BEGIN
select count(*) from api.metrics m where vessel_id = _vessel_id;
delete from api.metrics m where vessel_id = _vessel_id;
select * from api.metadata m where vessel_id = _vessel_id;
delete from api.logbook l where vessel_id = _vessel_id;
delete from api.moorages m where vessel_id = _vessel_id;
delete from api.stays s where vessel_id = _vessel_id;
delete from api.metadata m where vessel_id = _vessel_id;
RETURN True;
END
$delete_account$ language plpgsql security definer;

0 comments on commit 53b25e1

Please sign in to comment.