Skip to content

❓ How to determine if database is not yet versioned without cathing an exception #27

Description

@someniatko

First I want to thank you for this wonderful library. This is exactly what I was looking for: no query builders, heavy set of dependencies, and especially I want to thank you that symfony/console integration is put in a separate package, unlike the doctrine/migrations and phinx. My use-case is a separate library for domain objects, which I do re-use in my high-level app package, so no dependencies on CLI tools is great. 💗

Here is my question: I want to implement fully automatic database migration, whether it is first deployment or just an update. I use it like so:

        $migrator = new Migration(
            $this->psr7Uri,
            self::MIGRATIONS_DIR
        );

        foreach (self::SUPPORTED_SCHEMES as $scheme => $className) {
            $migrator->registerDatabase($scheme, $className);
        }

        $migrator->update(); // might throw DatabaseNotVersionedException

For now I have to catch the DatabaseNotVersionedException and call $migrator->createVersion() when appropriate. However, I would like to not depend on exception catching and just be able to check if DB is already versioned via some convenience method, like $migrator->isDatabaseVersioned(). Is it not possible for now, or do I miss something?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions