-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with the async migrations #84
Comments
The tasks are necessary, otherwise the migrations will run into a deadlock now that we lock the migrations table. So you would need to disable the migration lock too. Furthermore, the code is already complex, so I am a bit worried about adding more cases. I wonder if there are other things we could do? We have recently added a before_migration callback, maybe that can be used instead? |
The thing about triplex is that every time we create a new tenant (which is a schema on postgres) we run the migrations from a One solution maybe would be changing triplex to not run migrations when creating a new tenant at all, and instead use Closing for now, as there are 2 possible solutions. Thanks for the quick answer! |
Environment
Current behavior
So, we are trying to support ecto 3 on triplex (PR ateliware/triplex#61), and we stumbled in a problem: we cannot run a
CREATE SCHEMA "a"
and the migrations for the prefix"a"
inside the same transaction, because now the migrations are ran inside aTask.async
, so the db connection will not be the same and then we get a** (Postgrex.Error) ERROR 3F000 (invalid_schema_name) schema "a" does not exist
for the migrations.A sample code would be:
And the error you will get on ecto 3 is:
Expected behavior
So with ecto 2 the sample code runs smoothly, and migrates everything, because all the migrations are run inside of the same process of the transaction.
My suggestion for a solution would be an
async
option forEcto.Migrator.up/4
,Ecto.Migrator.down/4
andEcto.Migrator.run/3,4
, that could betrue
by default, but iffalse
, it will not run the migrations on aTask.async
.I can work on that if you want.
The text was updated successfully, but these errors were encountered: