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