Imperative Migrations with a TypeScript DSL
## Problem Not all migrations can be declarative. For example, we need to add a custom index for performance reasons. We also need this as an escape hatch for anything prisma schema doesn't support. Lastly, we also need this for data migrations. This is very important for any serious apps using prisma migrate. ## Suggested solution A new command: `prisma migrate create` This will create the necessary migration files. Similar as `prisma migrate save` but the files are just stubbed out. Then the user will open the stubbed migration file and add their custom migration code. Perhaps the imperative migration file can look something like this: ```ts import {migrate} from '@prisma/migrate` migrate({ async up(prisma) { // SQL migration await prisma.executeRaw(`some SQL stuff`) // Data migration await prisma.someModel.create(/*..*/) }, async down(prisma) { await prisma.someModel.delete(/*..*/) await prisma.executeRaw(`undo some SQL stuff`) } }) ```
Posted by flybayer on Jul 1, 2020, 3:19 AM
Tags
Related issues
- The issue is really the extreme difficulty of programming them, especially for anything sequential (rather than combinatorial).
- I probably could have beared with it if it was only limited to programming, but it showing up in creative fields has made me feel all sor...
- I hate that I'm in deep enough to know what you mean.
- The biggest problem with “AI” is that big corps are shoving it down our throats.
- in the middel of a coding session with 5.6 sol.
- [Hero Run] 535B-A23B on 18T tokens
Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments
reliability (Other)
The issue is really the extreme difficulty of programming them, especially for anything sequential (rather than combinatorial).
I probably could have beared with it if it was only limited to programming, but it showing up in creative fields has made me feel all sor...
I hate that I'm in deep enough to know what you mean.
The biggest problem with “AI” is that big corps are shoving it down our throats.
in the middel of a coding session with 5.6 sol.
[Hero Run] 535B-A23B on 18T tokens
I hate that this is how AI is being used..
inexperienced protobuf user here -- why do non-googlers generally use protobuf?
Imperative Migrations with a TypeScript DSL
## Problem Not all migrations can be declarative. For example, we need to add a custom index for performance reasons. We also need this as an escape hatch for anything prisma schema doesn't support. Lastly, we also need this for data migrations. This is very important for any serious apps using prisma migrate. ## Suggested solution A new command: `prisma migrate create` This will create the necessary migration files. Similar as `prisma migrate save` but the files are just stubbed out. Then the user will open the stubbed migration file and add their custom migration code. Perhaps the imperative migration file can look something like this: ```ts import {migrate} from '@prisma/migrate` migrate({ async up(prisma) { // SQL migration await prisma.executeRaw(`some SQL stuff`) // Data migration await prisma.someModel.create(/*..*/) }, async down(prisma) { await prisma.someModel.delete(/*..*/) await prisma.executeRaw(`undo some SQL stuff`) } }) ```
Comments (0)
No comments yet. Start the discussion.