試著開一張 table
首先留意到的是 remix 社群其實也遇到一個經典兩難
model Session {
id String @id
shop String
state String
isOnline Boolean @default(false)
scope String?
expires DateTime?
accessToken String
userId BigInt?
firstName String?
lastName String?
email String?
accountOwner Boolean @default(false)
locale String?
collaborator Boolean? @default(false)
emailVerified Boolean? @default(false)
}
這是預設驗證 table
為了在 js 操作屬性方便 使用 camcelCase 而且對應的 table name 就是 Session
但在 postgres 社群 通常會用 全小寫 + 底線 + 複數當作 table name
然後 欄位會用 snake_case
我決定不碰 Session 但我設計的 table 都要兼顧設計
model RecommendationSet {
id String @id @map("id")
shop String @map("shop")
title String @map("title")
createdAt DateTime @map("created_at")
updatedAt DateTime @map("updated_at")
@@map("recommendation_sets")
}
這樣即可
改好之後 在本機開發只需要輸入
npm run prisma migrate dev
開發資料庫就更新了
至於正式主機
npm run setup
正式資料庫就更新了