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

A side remark:
You should not alter other app’s database tables. This is really bad practice, especially as it might break the original app any time, they change their DB schema.

Just to warn you and to have a warning in case anyone stumbles later over this.