Blitzjs0.25->0.29의 upgrade

Breaking Change


0.28


isAuthorized의 API 변경 사항


// blitz.config.js
-const { sessionMiddleware, unstable_simpleRolesIsAuthorized } = require("@blitzjs/server")
+const { sessionMiddleware, simpleRolesIsAuthorized } = require("@blitzjs/server")

module.exports = {
  middleware: [
    sessionMiddleware({
-      unstable_isAuthorized: unstable_simpleRolesIsAuthorized,
+      isAuthorized: simpleRolesIsAuthorized,
    }),
  ],

0.29


prisma2.13+Support DB와 함께 migrate


이거 커요.
Prisma2.13 릴리즈
Prism 자체는 seed에 대응하고findFirst의 API를 제공하는 등 대폭 변경됐다.
blitz.js 지자체는 이 변경을 받아들여 CLI의 인터페이스가 Prisma에 적합하도록 결정했다.[1]
이상에 따라 프리스마migrate가 필요합니다.
공식 문서에 따라 집행하다.

1) introspect


[email protected]그럼 blitz prismaprisma명령입니다.
introspect는 다음과 같이 실행됩니다.
$ blitz prisma introspect
prisma introspect에서 실행하면 env 파일을 읽을 수 없습니다.
Introspecting based on datasource defined in db/schema.prisma …
Error: Error in datamodel: ErrorCollection { errors:
[EnvironmentFunctionalEvaluationError
{ var_name: "DATABASE_URL", span: Span { start: 155, end: 174 } }] }
Introspecting based on datasource defined in db/schema.prisma …

✔ Introspected 11 models and wrote them into db/schema.prisma in 164ms

*** WARNING ***

These DateTime fields were enriched with `@updatedAt` information taken from the previous Prisma schema.
- Model "Hoge", field: "updatedAt"
...

Run prisma generate to generate Prisma Client.

blitz prisma migrate dev를 실행할 수 없습니다.


제 상황은요[email protected]@0.25를 사용했기 때문에myapp/package.json@prisma/cli2.7.1입니다.
최신을 가져오다.
신속blitz new myAppName([email protected])에서 생성된 패키지입니다.복제 json[email protected].
"@prisma/cli": "~2.14",
"@prisma/client": "~2.14",
"blitz": "0.29.2",
"react": "0.0.0-experimental-3310209d0",
"react-dom": "0.0.0-experimental-3310209d0",
"react-error-boundary": "3.1.0",
"typescript": "4.1.3",
"zod": "1.11.11"
@prisma/cli가 업데이트되었습니다.

2) If you have a prisma/migrations folder, delete, move, rename, or otherwise archive this folder.


삭제db/migrations하거나 다른 폴더로 피합니다.

3) Initialize a new migration history by running the following command:


migrate를 실행합니다.
$ prisma migrate dev --preview-feature
실행 사용자 권한이 부족하면 다음과 같은 오류가 발생합니다.
내부적으로 shoadow 데이터베이스를 만들기 위해서다.
참조

Error: A migration failed when applied to the shadow database:

P3014
Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases.  More info: https://pris.ly/d/migrate-shadow. Original error: Error code: P1010
여기. 권한 조정 후 집행.

수고하셨습니다!


나의 상황은 이렇게 해서 이동을 완성했다.seed 손실이 크지만 피처가 계획되어 있으니 기다려 주세요!
각주
https://github.com/blitz-js/blitz/discussions/1611 ↩︎

좋은 웹페이지 즐겨찾기