Do Automatic Transaction on a database insert

Hi is there a way to do a automated database transaction in up() method of migration model ?

Hi @EmadFani!

It should be automated by default.
Problem is, that table creations can’t be rolled back in most databases (table creation commits transaction)

maybe my Question was’t clear enough .
i’m looking for a way that i can write a query in some place that when a user does a transaction the wreaten code automatically generates an item in another database.
for example we have 2 tables

  • product
  • transaction

i want to be able to increment a product field(total_sell)
when the transaction is inserted to database

(i know i can do it by writing a class or method and call it - but i want to do it automatically so every time a insert transaction does take action in my “transaction” table a new increment does take action in my “product” increment field)

Seems like a thing that can be solved with databases triggers.

You can take a look into them or tell what databases you are using and I might be able to help lil bit more