Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Roni's avatar
Level 33

Is there a check to skip a specific migration for unit tests in a migration class?

For example

 public function up()
    {
        If ( ! <test indicator>){
            // migrate stuff here
        }
    } 


0 likes
2 replies
bobbybouwmann's avatar
Level 88

You can check on environment or check if you currently run the tests

public function up()
{
    if (app()->environment() === 'testing') {
        // Do your thing
    }

    // An alternative would be this
    if (app()->runningUnitTests()) {
        // Do your thing
    }
}
4 likes

Please or to participate in this conversation.