Ecto transaction how to cross different DB

My project is depend two different databases, MySQL and Postgres. How can I keep transaction when update rows cross these two databases tables.

You can’t, as neither MySQL nor Postgres were able to do cross-DB transactions. Not even if you were using the same RDBMSs on both ends.

You’ll probably need to use sagas.


You can use the mysql_fdw plugin for PostgreSQL to add the mysql server into the postgresql server and then you can access them all. FDW’s don’t support write transactions directly however with appropriate carefulness and ordering of updates (assuming you only need to write once into the FDW side) you can emulate it well enough that it may as well be, which is far better than accessing both distinctly. :slight_smile:

1 Like