I want to create column with the following definition
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE now(),
But when I type in schema.prisma
updated_at DateTime @updatedAt @db.DateTime(0)
Then I obtains table with column:
`updated_at` datetime NOT NULL,
How to add ON UPDATE now()
to this column using prisma? I use MySQL/MariaDB.
References:
Connected problem
https://github.com/prisma/prisma/issues/5799#issuecomment-894631317
Article about ON UPDATE
Based on the client reference it seems that the client itself is responsible for providing the updated at DATETIME value instead of the way you're wanting it (to be done in the DB server).
If you really need the table/column definition to be exactly as you want, I would suggest creating or modifying the table directly in SQL and then using introspect to import the definition in your schema.
You could even add the definitions to your prisma migration files as these are just plain sql files. How to do this can be found in the Customizing Migrations article