Ville
11/26/2020, 10:53 PMRyan
11/27/2020, 7:37 AMschema.prisma
and you can use it as described here.
2. Could you explain more what you mean by a programmatic API?
3. The validation layer would be separate from the Prisma schema, you would need to use something like yup or zod to validate the requests. You can add database constraints via Prisma and that will be validated, but the application level validation needs to be separate.
4. Migrations are currently experimental but we recently added a message here with an early access Migrate that supports imperative migrations i.e. adding SQL statements in the form of constraints, procedures and so on.
5. Currently we only support SQL, and we have documentation on how to use that here. We are also looking for feedback so do provide us with how this can be improved and also with your use case for JS in Migrations so that we can consider those.
Let me know if this helps 🙂Ville
11/27/2020, 11:43 AMcli.migrate()
or cli.generate()
The reason why I'm asking is that more and more tools need a watcher based builder. Would be pretty cool, if all these could use single watcher and invoked by some master process.
3. Do you have plans to add any validation layer support? I wouldn't want to be able to push anything unwanted to the database, and wrapping all the updates and creates is super tedious. Unfortunately SQL schema often is not good enough validation layer for the data.
5. There might be some business logic that I want to apply in database as well. Let's say I want to decapitalize all the email fields. Or pull some data from external source and populate it to database. Or change the formatting of phone number. These are operations that would require JS based migrations. Most of the time SQL is enough, but there will be cases when more complicated migration logic is needed.Ville
12/02/2020, 12:40 PMRyan
12/02/2020, 1:08 PMexec
.
3. Validation for now can be added by SQL checks and constraints, but for fine-grained validation you would need to stick to the application layer.
5. Currently we do not support JS/TS migrations, but we are open to use cases and feedback in the #product-feedback channel. We are collecting use cases for programmatic migrations and know how many developers require them 🙂
I would suggest trying our Migrate workflow and provide feedback on the same so that we can take that into consideration 🙂