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

createMigrationTable() public method

Create the migration table to track migrations with.
public createMigrationTable ( ) : boolean
return boolean Whether or not the table was created.
    public function createMigrationTable()
    {
        $this->validate();
        if ($this->migrationTableCreated) {
            return false;
        }
        $this->connect();
        if ($this->connection->getSchemaManager()->tablesExist([$this->migrationsTableName])) {
            $this->migrationTableCreated = true;
            return false;
        }
        $columns = [$this->migrationsColumnName => new Column($this->migrationsColumnName, Type::getType('string'), ['length' => 255])];
        $table = new Table($this->migrationsTableName, $columns);
        $table->setPrimaryKey([$this->migrationsColumnName]);
        $this->connection->getSchemaManager()->createTable($table);
        $this->migrationTableCreated = true;
        return true;
    }

Usage Example

Example #1
0
 private function markVersion($direction)
 {
     if ($direction == 'up') {
         $action = 'insert';
     } else {
         $action = 'delete';
     }
     $this->configuration->createMigrationTable();
     $this->connection->{$action}($this->configuration->getMigrationsTableName(), [$this->configuration->getMigrationsColumnName() => $this->version]);
 }
All Usage Examples Of Doctrine\DBAL\Migrations\Configuration\Configuration::createMigrationTable