diff --git a/gso/migrations/env.py b/gso/migrations/env.py
index a1f9b9fcdbb9088dc846a4273a9a12eff786baf6..4d84cfb15787fc357dd96857fb97b4cee13b80a8 100644
--- a/gso/migrations/env.py
+++ b/gso/migrations/env.py
@@ -1,11 +1,9 @@
 import logging
-import os
 
-import orchestrator
 from alembic import context
 from orchestrator.db.database import BaseModel
 from orchestrator.settings import app_settings
-from sqlalchemy import engine_from_config, pool
+from sqlalchemy import engine_from_config, pool, text
 
 # this is the Alembic Config object, which provides
 # access to the values within the .ini file in use.
@@ -17,17 +15,8 @@ logger = logging.getLogger("alembic.env")
 
 config.set_main_option("sqlalchemy.url", app_settings.DATABASE_URI)
 
-# add your model's MetaData object here
-# for 'autogenerate' support
-# from myapp import mymodel
-# target_metadata = mymodel.Base.metadata
 target_metadata = BaseModel.metadata
 
-# other values from the config, defined by the needs of env.py,
-# can be acquired:
-# my_important_option = config.get_main_option("my_important_option")
-# ... etc.
-
 
 def run_migrations_offline() -> None:
     """Run migrations in 'offline' mode.
@@ -85,8 +74,10 @@ def run_migrations_online() -> None:
     )
     try:
         with context.begin_transaction():
+            connection.execute(text("SELECT pg_advisory_xact_lock(1000);"))
             context.run_migrations()
     finally:
+        connection.execute(text("SELECT pg_advisory_unlock(1000);"))
         connection.close()