-- create a utility that bootstraps a user
CREATE OR REPLACE FUNCTION bootstrap_users() RETURNS void AS $$
DECLARE
 test_user VARCHAR(64);
BEGIN
-- non guid used for test user.  test user won't be in actual database,     but '1' is much easier to script that 242423-42-4-24234
-- password is jam123
    SELECT id INTO STRICT test_user FROM users WHERE id = '1';
    
    UPDATE users SET first_name = 'Test', last_name = 'User', email = 'test@jamkazam.com', remember_token = 'NQubl-z16Em94tnSdofObw', password_digest = '$2a$10$QyaNTLVX5DAaJ.JL21kDWeUQqdh3Qh7JQbdRgE82x1Cib7HWNcHXC', email_confirmed=true, musician=true WHERE id = '1';
    
    EXCEPTION
        WHEN NO_DATA_FOUND THEN
            INSERT INTO users (id, first_name, last_name, email, remember_token, password_digest, email_confirmed, musician) VALUES ('1', 'Test', 'User', 'test@jamkazam.com', 'NQubl-z16Em94tnSdofObw', '$2a$10$QyaNTLVX5DAaJ.JL21kDWeUQqdh3Qh7JQbdRgE82x1Cib7HWNcHXC', true, true);
            RETURN;
        WHEN TOO_MANY_ROWS THEN
            RAISE EXCEPTION 'user id 1 not unique';
END;
$$ LANGUAGE plpgsql;
 
select bootstrap_users();

