Skip to content

Testing migrations in SQLModel/SQLAlchemy environment #27

@eremeevfd

Description

@eremeevfd

Hello and thank you for a great library! This is definitely a modern library and it brings me a lot of joy.

But I have a question or maybe a proposition. When we're working with Django and run tests it creates Database from scratch and also applies migrations every time, so we can check if migrations are actually working before deploying.

Also when we're working with SQLModel/SQLAlchemy we recreated manually this behavior with fixtures, so we could test migrations as well.

But with pglite it seems impossible currently, because there is always on table creation from metadata:

    # Create session - prefer SQLModel if available
    if HAS_SQLMODEL and SQLModelSession is not None:
        session = SQLModelSession(pglite_engine)
        # Create tables if using SQLModel with retry logic
        if SQLModel is not None:
            for attempt in range(3):
                try:
                    SQLModel.metadata.create_all(pglite_engine)

So, would it make sense to move this functionality to separate function/fixture or maybe add some pytest flag to disable this behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions