KeystoneJS Prisma Migration
migrating an existing PostGreSQL database with the KeystoneJS ORM takes a bit of doc reading. Essentially mashing the Command Line - Keystone 6 Docs and link articles together
while in the ./backend
keystonejs root directory
mkdir -p migrations/0_init
npx prisma migrate diff \
--from-empty \
--to-schema-datamodel schema.prisma \
--script > migrations/0_init/migration.sql
npx prisma migrate resolve --applied 0_init
run below command to double check
yarn keystone build && keystone prisma migrate deploy
File tree for reference
.
βββ Dockerfile
βββ README.md
βββ access.ts
βββ auth.ts
βββ crontab
βΒ Β βββ subscription_cron.ts
βββ keystone.ts
βββ migrations
βΒ Β βββ 0_initial
migration.sql <---- ** here
βββ mutations
βΒ Β βββ addToCart.ts
βΒ Β βββ checkout.ts
βΒ Β βββ contact.ts
βΒ Β βββ sampleMutation.ts
βββ package.json
βββ prepareToUpload.ts
βββ public
βΒ Β βββ assets
βΒ Β βββ seedfiles
βΒ Β βββ styles
βββ schema.graphql
βββ schema.prisma
βββ schema.ts
βββ schemas
βββ tsconfig.json
βββ types.ts
βββ yarn.lock
Still not working
problem
Still having problems with this build. For now I connect my dev app environment with my production database and run yarn dev
to update the schema, probably not a good idea but it's what works for now