rage / mooc.fi

https://mooc.fi
5 stars 6 forks source link

Chore: upgrade prisma #1190

Closed mipyykko closed 1 year ago

mipyykko commented 1 year ago

Finally give in and upgrade Prisma to a modern version, hopping right from 2.x to 4.x. This called for replacing the deprecated nexus-plugin-prisma with a forked version, but the changes there have been relatively minor.

Main Prisma-related refactors in this PR are mainly just to rename the primary/foreign/unique keys and indexes to use the new default convention. Prisma schema is rewritten using the introspection feature, although some manual changes are still needed -- now the Postgres Decimal columns would be automatically cast to Decimal.js objects, which would just break things, so I force them to be Float as before.

Now that Prisma can be upgraded, we should also use its new features -- for example transactions are useful. Also, previously Prisma did not cascade delete even if the DB schema was set up to do so, but now it does.

codecov[bot] commented 1 year ago

Codecov Report

Merging #1190 (a1eadc8) into master (a9a548f) will decrease coverage by 0.27%. The diff coverage is 34.86%.

@@            Coverage Diff             @@
##           master    #1190      +/-   ##
==========================================
- Coverage   65.51%   65.24%   -0.27%     
==========================================
  Files         124      124              
  Lines        5222     5280      +58     
  Branches     1160     1225      +65     
==========================================
+ Hits         3421     3445      +24     
- Misses       1677     1711      +34     
  Partials      124      124              
Flag Coverage Δ
backend 65.24% <34.86%> (-0.27%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
backend/api/routes/completions.ts 58.02% <0.00%> (-0.37%) :arrow_down:
backend/api/routes/progress.ts 30.85% <0.00%> (-0.91%) :arrow_down:
...nsumer/common/userCourseProgress/BAI/completion.ts 14.28% <0.00%> (-0.43%) :arrow_down:
backend/graphql/Completion/model.ts 40.24% <0.00%> (-0.50%) :arrow_down:
backend/graphql/Completion/queries.ts 24.52% <0.00%> (-1.48%) :arrow_down:
backend/graphql/StudyModule/model.ts 55.55% <0.00%> (-2.14%) :arrow_down:
backend/graphql/Tag.ts 41.46% <0.00%> (-0.34%) :arrow_down:
backend/graphql/User/model.ts 35.75% <0.00%> (-0.89%) :arrow_down:
backend/graphql/UserCourseProgress.ts 30.25% <0.00%> (-0.26%) :arrow_down:
backend/graphql/UserCourseServiceProgress.ts 49.05% <0.00%> (ø)
... and 13 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more