Search code examples
nestjstypeorm

typeorm `cascade: true` is not functioning in mariadb


I set cascade: true in the many-to-one relation. But when I checked the Mariadb database, the foreign key has "no action" in "on update" or "on delete" conditions. Is it bug, or can I solve it without onDelete: "CASCADE", onUpdate: "CASCADE"?


Solution

  • cascade: true is something used by typeorm itself, and will not change your database schema. It means when modifying that relation from your code, typeorm will make sure to do the same in the database. If you want the constraint to be saved to the database itself you use onDelete: "CASCADE" and onUpdate: "CASCADE"