Skip to content

Commit

Permalink
[mod] hasura relation (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
大浦 翼 committed Jun 1, 2023
1 parent 415f69e commit b3717cb
Show file tree
Hide file tree
Showing 20 changed files with 287 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
container_name: "seeds_hasura"
ports:
- "8082:8080"
restart: always
# restart: always
volumes:
- ./hasura:/hasura
environment:
Expand Down
8 changes: 8 additions & 0 deletions hasura/metadata/databases/default/tables/public_bureaus.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
table:
name: bureaus
schema: public
array_relationships:
- name: user_details
using:
foreign_key_constraint_on:
column: bureau_id
table:
name: user_details
schema: public
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
table:
name: categories
schema: public
array_relationships:
- name: skills
using:
foreign_key_constraint_on:
column: category_id
table:
name: skills
schema: public
12 changes: 12 additions & 0 deletions hasura/metadata/databases/default/tables/public_chapters.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
table:
name: chapters
schema: public
object_relationships:
- name: curriculum
using:
foreign_key_constraint_on: curriculum_id
array_relationships:
- name: records
using:
foreign_key_constraint_on:
column: chapter_id
table:
name: records
schema: public
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
table:
name: curriculum_skills
schema: public
object_relationships:
- name: curriculum
using:
foreign_key_constraint_on: curriculum_id
- name: skill
using:
foreign_key_constraint_on: skill_id
19 changes: 19 additions & 0 deletions hasura/metadata/databases/default/tables/public_curriculums.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
table:
name: curriculums
schema: public
object_relationships:
- name: skill
using:
foreign_key_constraint_on: skill_ids
array_relationships:
- name: chapters
using:
foreign_key_constraint_on:
column: curriculum_id
table:
name: chapters
schema: public
- name: curriculum_skills
using:
foreign_key_constraint_on:
column: curriculum_id
table:
name: curriculum_skills
schema: public
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
table:
name: departments
schema: public
array_relationships:
- name: user_details
using:
foreign_key_constraint_on:
column: department_id
table:
name: user_details
schema: public
8 changes: 8 additions & 0 deletions hasura/metadata/databases/default/tables/public_grades.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
table:
name: grades
schema: public
array_relationships:
- name: user_details
using:
foreign_key_constraint_on:
column: grade_id
table:
name: user_details
schema: public
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
table:
name: project_skills
schema: public
object_relationships:
- name: project
using:
foreign_key_constraint_on: project_id
- name: skill
using:
foreign_key_constraint_on: skill_id
10 changes: 10 additions & 0 deletions hasura/metadata/databases/default/tables/public_project_users.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
table:
name: project_users
schema: public
object_relationships:
- name: project
using:
foreign_key_constraint_on: project_id
- name: role
using:
foreign_key_constraint_on: role_id
- name: user
using:
foreign_key_constraint_on: user_id
15 changes: 15 additions & 0 deletions hasura/metadata/databases/default/tables/public_projects.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
table:
name: projects
schema: public
array_relationships:
- name: project_skills
using:
foreign_key_constraint_on:
column: project_id
table:
name: project_skills
schema: public
- name: project_users
using:
foreign_key_constraint_on:
column: project_id
table:
name: project_users
schema: public
15 changes: 15 additions & 0 deletions hasura/metadata/databases/default/tables/public_records.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
table:
name: records
schema: public
object_relationships:
- name: chapter
using:
foreign_key_constraint_on: chapter_id
- name: user
using:
foreign_key_constraint_on: user_id
array_relationships:
- name: teachers
using:
foreign_key_constraint_on:
column: record_id
table:
name: teachers
schema: public
8 changes: 8 additions & 0 deletions hasura/metadata/databases/default/tables/public_roles.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
table:
name: roles
schema: public
array_relationships:
- name: project_users
using:
foreign_key_constraint_on:
column: role_id
table:
name: project_users
schema: public
36 changes: 36 additions & 0 deletions hasura/metadata/databases/default/tables/public_skills.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
table:
name: skills
schema: public
object_relationships:
- name: category
using:
foreign_key_constraint_on: category_id
- name: type
using:
foreign_key_constraint_on: type_id
array_relationships:
- name: curriculum_skills
using:
foreign_key_constraint_on:
column: skill_id
table:
name: curriculum_skills
schema: public
- name: curriculums
using:
foreign_key_constraint_on:
column: skill_ids
table:
name: curriculums
schema: public
- name: project_skills
using:
foreign_key_constraint_on:
column: skill_id
table:
name: project_skills
schema: public
- name: user_skills
using:
foreign_key_constraint_on:
column: skill_id
table:
name: user_skills
schema: public
7 changes: 7 additions & 0 deletions hasura/metadata/databases/default/tables/public_teachers.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
table:
name: teachers
schema: public
object_relationships:
- name: record
using:
foreign_key_constraint_on: record_id
- name: user
using:
foreign_key_constraint_on: user_id
15 changes: 15 additions & 0 deletions hasura/metadata/databases/default/tables/public_types.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
table:
name: types
schema: public
array_relationships:
- name: skills
using:
foreign_key_constraint_on:
column: type_id
table:
name: skills
schema: public
- name: user_details
using:
foreign_key_constraint_on:
column: type_id
table:
name: user_details
schema: public
16 changes: 16 additions & 0 deletions hasura/metadata/databases/default/tables/public_user_details.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
table:
name: user_details
schema: public
object_relationships:
- name: bureau
using:
foreign_key_constraint_on: bureau_id
- name: department
using:
foreign_key_constraint_on: department_id
- name: grade
using:
foreign_key_constraint_on: grade_id
- name: type
using:
foreign_key_constraint_on: type_id
- name: user
using:
foreign_key_constraint_on: user_id
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
table:
name: user_skills
schema: public
object_relationships:
- name: skill
using:
foreign_key_constraint_on: skill_id
- name: user
using:
foreign_key_constraint_on: user_id
36 changes: 36 additions & 0 deletions hasura/metadata/databases/default/tables/public_users.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
table:
name: users
schema: public
array_relationships:
- name: project_users
using:
foreign_key_constraint_on:
column: user_id
table:
name: project_users
schema: public
- name: records
using:
foreign_key_constraint_on:
column: user_id
table:
name: records
schema: public
- name: teachers
using:
foreign_key_constraint_on:
column: user_id
table:
name: teachers
schema: public
- name: user_details
using:
foreign_key_constraint_on:
column: user_id
table:
name: user_details
schema: public
- name: user_skills
using:
foreign_key_constraint_on:
column: user_id
table:
name: user_skills
schema: public
44 changes: 44 additions & 0 deletions hasura/migrations/default/1685636429787_auto/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ALTER TABLE ONLY public.chapters
ADD CONSTRAINT chapters_curriculum_id_fkey FOREIGN KEY (curriculum_id) REFERENCES public.curriculums(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.curriculum_skills
ADD CONSTRAINT curriculum_skills_curriculum_id_fkey FOREIGN KEY (curriculum_id) REFERENCES public.curriculums(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.curriculum_skills
ADD CONSTRAINT curriculum_skills_skill_id_fkey FOREIGN KEY (skill_id) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.curriculums
ADD CONSTRAINT curriculums_skill_ids_fkey FOREIGN KEY (skill_ids) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.project_skills
ADD CONSTRAINT project_skills_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.project_skills
ADD CONSTRAINT project_skills_skill_id_fkey FOREIGN KEY (skill_id) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.project_users
ADD CONSTRAINT project_users_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.project_users
ADD CONSTRAINT project_users_role_id_fkey FOREIGN KEY (role_id) REFERENCES public.roles(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.project_users
ADD CONSTRAINT project_users_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.records
ADD CONSTRAINT records_chapter_id_fkey FOREIGN KEY (chapter_id) REFERENCES public.chapters(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.records
ADD CONSTRAINT records_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.skills
ADD CONSTRAINT skills_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.categories(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.skills
ADD CONSTRAINT skills_type_id_fkey FOREIGN KEY (type_id) REFERENCES public.types(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.teachers
ADD CONSTRAINT teachers_record_id_fkey FOREIGN KEY (record_id) REFERENCES public.records(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.teachers
ADD CONSTRAINT teachers_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.user_details
ADD CONSTRAINT user_details_bureau_id_fkey FOREIGN KEY (bureau_id) REFERENCES public.bureaus(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.user_details
ADD CONSTRAINT user_details_department_id_fkey FOREIGN KEY (department_id) REFERENCES public.departments(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.user_details
ADD CONSTRAINT user_details_grade_id_fkey FOREIGN KEY (grade_id) REFERENCES public.grades(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.user_details
ADD CONSTRAINT user_details_type_id_fkey FOREIGN KEY (type_id) REFERENCES public.types(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.user_details
ADD CONSTRAINT user_details_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.user_skills
ADD CONSTRAINT user_skills_skill_id_fkey FOREIGN KEY (skill_id) REFERENCES public.skills(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.user_skills
ADD CONSTRAINT user_skills_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE RESTRICT ON DELETE RESTRICT;

0 comments on commit b3717cb

Please sign in to comment.