Add attribute to nc database

Hello everyone, I would like to add a new attribute to the oc_deck_cards table in the Deck app.

I get the error message:

In MigrationService.php line 370:
                                                      
  The version Version_AddMilestoneToDeckCards is unknown.  
                                                      

migrations:execute <application> <version>

My migration file (/lib/Migration/Version_AddMilestoneToDeckCards.php) looks like this:

use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;

class Version_AddMilestoneToDeckCards extends SimpleMigrationStep {

    public function changeSchema(IOutput $output, ISchemaWrapper $schema, array $options) {
        // Retrieve the ‘oc_deck_cards’ table
        $table = $schema->getTable(‘oc_deck_cards’);

        // Add a new column ‘milestone’ of type ‘varchar(255)’ to the table
        $table->addColumn(‘milestone’, ‘string’, [
            ‘length’ => 255,
            ‘notnull’ => false, // Optional field
        ]);

        // Return of the changed schema
        return $schema;
    }
}

Can anyone help me?

Your migration does not look corect.

Did you follow the steps as described in → the Developer Manual for Migrations ← ?

Allready this class looks wrong. It should look like this at the end (example):

class Version120000Date20250111170000 extends SimpleMigrationStep {

h.t.h.


Much and good luck,
ernolf

1 Like