DEV Community

Andy Allison
Andy Allison

Posted on

Postgres variables & clean up

Overview

We needed a little script that would clean up data for a user based on their id.

do
$$
    declare
        userId varchar(255) := '98584bc7-f06b-45cf-bfc3-d5224cf7b743';
    begin
        delete from "LoginAttempt" where "userId" = userId;
        delete from "LoginSuccess" where "userId" = userId;
        delete from "LoginFailed" where "userId" = userId;
        delete from "Provider" where "userId" = userId;
        delete from "User" where id = userId;
    end
$$
Enter fullscreen mode Exit fullscreen mode

Top comments (0)