Doctrine\DBAL\Migrations\Configuration\Configuration::hasVersionMigrated PHP Method

hasVersionMigrated() public method

Check if a version has been migrated or not yet
public hasVersionMigrated ( Version $version ) : boolean
$version Doctrine\DBAL\Migrations\Version
return boolean
    public function hasVersionMigrated(Version $version)
    {
        $this->connect();
        $this->createMigrationTable();
        $version = $this->connection->fetchColumn("SELECT " . $this->migrationsColumnName . " FROM " . $this->migrationsTableName . " WHERE " . $this->migrationsColumnName . " = ?", [$version->getVersion()]);
        return $version !== false;
    }

Usage Example

Example #1
0
 public function testSkipMigrateUp()
 {
     $version = new \Doctrine\DBAL\Migrations\Version($this->config, 1, 'Doctrine\\DBAL\\Migrations\\Tests\\Functional\\MigrationSkipMigration');
     $this->assertFalse($this->config->hasVersionMigrated($version));
     $version->execute('up');
     $schema = $this->connection->getSchemaManager()->createSchema();
     $this->assertFalse($schema->hasTable('foo'));
     $this->assertTrue($this->config->hasVersionMigrated($version));
 }
All Usage Examples Of Doctrine\DBAL\Migrations\Configuration\Configuration::hasVersionMigrated