diff --git a/src/main/resources/db/migration/V1.8__add_user_api_resources.sql b/src/main/resources/db/migration/V1.8__add_user_api_resources.sql new file mode 100644 index 0000000..d7769c2 --- /dev/null +++ b/src/main/resources/db/migration/V1.8__add_user_api_resources.sql @@ -0,0 +1,45 @@ +do +$$ +DECLARE + get_student_profile integer; + get_tutor_profile integer; + post_tutor_profile integer; + accept_invite integer; + tutor integer; + student integer; +BEGIN + +-- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'GET', '/student/profile'); + +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'GET', '/users/tutor/profile'); + +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'POST', '/users/tutor/profile'); + +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'POST', '/student/accept-invitation'); + +-- Grants +SELECT id into get_student_profile FROM qms_auth.api_resource WHERE path = '/student/profile' and method = 'GET'; +SELECT id into get_tutor_profile FROM qms_auth.api_resource WHERE path = '/users/tutor/profile' and method = 'GET'; +SELECT id into post_tutor_profile FROM qms_auth.api_resource WHERE path = '/users/tutor/profile' and method = 'POST'; +SELECT id into accept_invite FROM qms_auth.api_resource WHERE path = '/student/accept-invitation' and method = 'POST'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; +select id into student FROM qms_auth.role where name = 'student'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(get_student_profile, student); +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES( get_tutor_profile, tutor); +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(post_tutor_profile, tutor); +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(accept_invite, student); + +END; +$$; \ No newline at end of file diff --git a/src/main/resources/db/migration/V1.9__add_class_api_resources.sql b/src/main/resources/db/migration/V1.9__add_class_api_resources.sql new file mode 100644 index 0000000..4d11280 --- /dev/null +++ b/src/main/resources/db/migration/V1.9__add_class_api_resources.sql @@ -0,0 +1,22 @@ +do +$$ +DECLARE + get_class_details integer; + tutor integer; +BEGIN + +-- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'GET', '/class/(.*)'); + +-- Grants +SELECT id into get_class_details FROM qms_auth.api_resource WHERE path = '/class/(.*)' and method = 'GET'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(get_class_details, tutor); + +END; +$$; \ No newline at end of file diff --git a/src/main/resources/db/migration/V2.0__add_student_api.sql b/src/main/resources/db/migration/V2.0__add_student_api.sql new file mode 100644 index 0000000..615550a --- /dev/null +++ b/src/main/resources/db/migration/V2.0__add_student_api.sql @@ -0,0 +1,22 @@ +do +$$ +DECLARE + search_student integer; + tutor integer; +BEGIN + +-- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'POST', '/student/search'); + +-- Grants +SELECT id into search_student FROM qms_auth.api_resource WHERE path = '/student/search' and method = 'POST'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(search_student, tutor); + +END; +$$; diff --git a/src/main/resources/db/migration/V2.1__remove_student_from_class.sql b/src/main/resources/db/migration/V2.1__remove_student_from_class.sql new file mode 100644 index 0000000..05bf74a --- /dev/null +++ b/src/main/resources/db/migration/V2.1__remove_student_from_class.sql @@ -0,0 +1,22 @@ +do +$$ +DECLARE +remove_student integer; + tutor integer; +BEGIN + +-- Api Resource +INSERT INTO qms_auth.api_resource(method, path) +VALUES( 'DELETE', '/class/(\d+)/student/(\d+)'); + +-- Grants +SELECT id into remove_student FROM qms_auth.api_resource WHERE path = '/class/(\d+)/student/(\d+)' and method = 'DELETE'; + +select id into tutor FROM qms_auth.role where name = 'tutor'; + +/*generate question from ai*/ +INSERT INTO qms_auth.role_api_resource(resource_id, role_id) +VALUES(remove_student, tutor); + +END; +$$;