I have recently started creating my first app for NextCloud, and I have a issue when I am trying to create my first migration.
Inside “nfinkop\lib\Migratio” I only have one single migration file and it’s content looks like this
<?php
declare(strict_types=1);
namespace OCA\NfInkop\Migrations;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
/**
* This script will create the necessary database tables for nfinkop app
*/
class Version000002Date202401250830 extends SimpleMigrationStep {
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
// Supplier
//if (!$schema->hasTable('nfinkop_supplier')) {
// $table = $schema->createTable('nfinkop_supplier');
// $table->addColumn('id', 'integer', ['autoincrement' => true,'notnull' => true,]);
// $table->addColumn('name', 'string', ['notnull' => true, 'length' => 200]);
// $table->addColumn('last_order', 'date');
// $table->setPrimaryKey(['id']);
// //$table->addIndex(['user_id'], 'nfinkop_user_id_index');
//}
// Products
//if(!$schema->hasTable('nfinkop_products')){
// $table = $schema->createTable('nfinkop_products');
//}
//
//// Orders
//if(!$schema->hasTable('nfinkop_orders')){
// $table = $schema->createTable('nfinkop_orders');
//}
return $schema;
}
}
The error message I get (using docker exec -ti master-nextcloud-1 tail -f data/nextcloud.log)
"user":"admin","app":"PHP","method":"POST","url":"/index.php/settings/apps/enable","message":"Cannot declare class OCA\\NfInkop\\Migrations\\Version000001Date202401250830, because the name is already in use at /var/www/html/apps-extra/nfinkop/lib/Migration/Version000001Date202401250830.php#0", ...