Closed pvi-github closed 2 months ago
Hello ... I'm adding and auto comment:
In the code i found this...
$ grep -r department_user_remove .
./internal/db/team/department.go: `CALL thunderdome.department_user_remove($1, $2);`,
./internal/db/migrations/20230823233842_create_funcs_procs_triggers.sql:CREATE OR REPLACE PROCEDURE thunderdome.department_user_remove(IN departmentid uuid, IN userid uuid)
./internal/db/migrations/20230823233842_create_funcs_procs_triggers.sql: CALL department_user_remove(temprow.id, userId);
./internal/db/migrations/20230823233842_create_funcs_procs_triggers.sql:DROP PROCEDURE thunderdome.department_user_remove(IN departmentid uuid, IN userid uuid);
It seems to be a PostgreSQL stored procedure. Is is only dealt with in a migration sql file : 20230823233842_create_funcs_procs_triggers.sql
And this file ends with a DROP PROCEDURE CALL... which seems weird if it is supposed to be called from the department.go file... maybe the DROP PROCEDURE should not be there ?
Hope that can help a bit.
Hello ... I'm adding and auto answer to comment:
I just added (manually) in PostgreSQL the (potentially) missing stored procedures...
CREATE OR REPLACE PROCEDURE thunderdome.organization_user_remove(orgid uuid, userid uuid)
LANGUAGE plpgsql
AS $$
DECLARE temprow record;
BEGIN
FOR temprow IN
SELECT id FROM thunderdome.organization_department WHERE organization_id = orgId
LOOP
CALL department_user_remove(temprow.id, userId);
END LOOP;
DELETE FROM thunderdome.team_user tu WHERE tu.team_id IN (
SELECT t.id
FROM thunderdome.team t
WHERE t.organization_id = orgId
) AND tu.user_id = userId;
DELETE FROM thunderdome.organization_user WHERE organization_id = orgId AND user_id = userId;
COMMIT;
END;
$$;
CREATE OR REPLACE PROCEDURE thunderdome.department_user_remove(departmentid uuid, userid uuid)
LANGUAGE plpgsql
AS $$
BEGIN
DELETE FROM thunderdome.team_user tu WHERE tu.team_id IN (
SELECT t.id
FROM thunderdome.team t
WHERE t.department_id = departmentId
) AND tu.user_id = userId;
DELETE FROM thunderdome.department_user WHERE department_id = departmentId AND user_id = userId;
COMMIT;
END;
$$;
=> Result : the error still occurs. So i'd be tempted to think that the missing procedure is in the GO code ?
Sorry for the delay I was on leave from working, I will look into this one as soon as possible.
Hello,
I installed for testing a fresh new thunder dome that in run with docker-compose.
I managed to create an admin user, a company, a department, a team and created a first story.
Then i made a user register himself and added it to the company.
After a few tests itried to delete the user and i received an error message: "procedure department_user_remove(uuid, uuid) does not exist"
The procedure is yet to be coded ? Or it was renamed but not completely yet ? I made a huge mistake ? What do you think ?
Here is where i am on git :
Here is the full log of docker-compose up --build