diff --git a/agenta-backend/agenta_backend/migrations/mongo_to_postgres/db_engine.py b/agenta-backend/agenta_backend/migrations/mongo_to_postgres/db_engine.py index 30aa53262..a13dce458 100644 --- a/agenta-backend/agenta_backend/migrations/mongo_to_postgres/db_engine.py +++ b/agenta-backend/agenta_backend/migrations/mongo_to_postgres/db_engine.py @@ -106,21 +106,11 @@ async def init_db(self): Initialize the database based on the mode and create all tables. """ async with self.engine.begin() as conn: - # Drop all existing tables (if needed) - # await conn.run_sync(Base.metadata.drop_all) # Create tables for model in models: await conn.run_sync(model.metadata.create_all) logger.info(f"Using {self.mode} database...") - async def remove_db(self) -> None: - """ - Remove the database based on the mode. - """ - async with self.engine.begin() as conn: - for model in models: - await conn.run_sync(model.metadata.drop_all) - @asynccontextmanager async def get_session(self) -> AsyncGenerator[AsyncSession, None]: session = self.async_session() diff --git a/agenta-backend/agenta_backend/migrations/mongo_to_postgres/migration.py b/agenta-backend/agenta_backend/migrations/mongo_to_postgres/migration.py index 7154b382d..76956c57f 100644 --- a/agenta-backend/agenta_backend/migrations/mongo_to_postgres/migration.py +++ b/agenta-backend/agenta_backend/migrations/mongo_to_postgres/migration.py @@ -34,7 +34,6 @@ ) from agenta_backend.migrations.mongo_to_postgres.utils import ( - drop_all_tables, create_all_tables, print_migration_report, store_mapping, @@ -501,7 +500,6 @@ async def transform_evaluation_scenario(scenario): async def main(): try: - await drop_all_tables() await create_all_tables(tables=tables) await migrate_collection("users", UserDB, transform_user) await migrate_collection("docker_images", ImageDB, transform_image) diff --git a/agenta-backend/agenta_backend/migrations/mongo_to_postgres/utils.py b/agenta-backend/agenta_backend/migrations/mongo_to_postgres/utils.py index 3e5d34545..c93167be6 100644 --- a/agenta-backend/agenta_backend/migrations/mongo_to_postgres/utils.py +++ b/agenta-backend/agenta_backend/migrations/mongo_to_postgres/utils.py @@ -25,16 +25,6 @@ migration_report = {} -async def drop_all_tables(): - """Drop all tables in the database.""" - async with db_engine.engine.begin() as conn: - await conn.run_sync(Base.metadata.reflect) - # Drop all tables with CASCADE option - for table in reversed(Base.metadata.sorted_tables): - await conn.execute(text(f"DROP TABLE IF EXISTS {table.name} CASCADE")) - print("\n====================== All tables are dropped.\n") - - async def create_all_tables(tables): """Create all tables in the database.""" async with db_engine.engine.begin() as conn: