Wait, you misplaced the grail? Cannot find Doctrine DBAL API docs

For writing Migration files I copy from existing apps and fall back to the actual implementation in 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php, which is a bit tedious.

For the hell of me I cannot find formal API docs of Doctrine compatible with NC use. The Doctrine reference contains a lot of information but apparently no API, at least not in a format like https://stable19--nextcloud-server.netlify.app/ for NC.

Googling produced no useable results. Is it normal to have no such docs? Am I supposed to build them myself?

Our docs are at Nextcloud developer documentation — Nextcloud latest Developer Manual latest documentation.

You shouldn’t need to know the doctrine internals. It can be even counter productive because apps are supposed to only use the exposed public API of Nextcloud. The more your app depends on doctrine, the more painful updating apps will be.

In a Migration file, one would typically create a table like this:

public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
    if (!$schema->hasTable('mytable')) {
        $table = $schema->createTable('mytable');
        $table->addColumn('id', 'integer', [
            'notnull' => true,
            'autoincrement' => true,
        ]);
        // more fields here
        $table->setPrimaryKey(['id']);
        return $schema;
    }

What operations are possible on the $table object seems to be subject to Doctrine definitions. If there is a place in NC documentation I would love to get a pointer.

In the NC docs you reference, searching for addColumn only yield links to the Tutorial and Migrations chapters. Neither of them gives a list of options to use.

It’s not documented very well and also the API abstraction has leaks where Doctrine methods are used directly, as you observed.

Being unable to find better docs I am working on Doctrine files for now. For those in a similar situation, there is much to be learned from Type.php, Column.php and Table.php. Start at the root of your installation (for me: /usr/local/www/devcloud).

This will give you the available types for addColumn():

grep 'public const' 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Types/Type.php

You can get an idea of what other arguments to addColumn() can be used by typing:

grep 'public function set' ./nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Schema/Column.php

For listing available methods on the table try:

grep 'public function' 3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Schema/Table.php