Target model users has no primary key attribute

Dear all -

Happy new year!

I installed the current version via yarn like described in the documentation.
Unfortunately, when I yarn start the app, I get the following issue:

Target model users has no primary key attribute

The database seems to be correct, in the table users, there is a field “id” set as Primary key.

Any idea?

Gabriel

Please provide more log information.
Log file location: storage\logs\main (request_xxx, system_xxx, system_error_xxx, sql_xxx)
Online log file management address: admin/settings/logger

system:

{"level":"warn","message":"access control config not exist, use default value","meta":{},"module":"application","submodule":"","method":"","app":"main","reqId":"c76c1098-4bc9-4085-a4dc-bfc610b91b9c","dataSourceKey":"main","timestamp":"2026-01-08 09:42:21"}
{"level":"error","message":"Target model users has no primary key attribute","meta":{"code":"error","error":{"status":503,"message":"Target model users has no primary key attribute","code":"APP_ERROR","command":{"name":"start"},"maintaining":true},"statusCode":200,"appName":"main"},"module":"gateway","submodule":"","method":"responseErrorWithCode","app":"main","reqId":"9462f7a4-06b7-4331-ac39-7d752b5b3fa8","dataSourceKey":"main","timestamp":"2026-01-08 10:01:02"}

SQL and request Log are blank.

System error log:

{"level":"error","message":"Target model users has no primary key attribute","stack":"Error: Target model users has no primary key attribute\n    at _BelongsToManyField.bind (c:\\nocobase\\XXX\\node_modules\\@nocobase\\database\\lib\\fields\\belongs-to-many-field.js:119:13)\n    at _Collection.<anonymous> (c:\\nocobase\\XXX\\node_modules\\@nocobase\\database\\lib\\collection.js:785:13)\n    at _Collection.emit (node:events:518:28)\n    at _Collection.emit (node:domain:489:12)\n    at _Collection.setField (c:\\nocobase\\XXX\\node_modules\\@nocobase\\database\\lib\\collection.js:410:10)\n    at EnsureAtomicity.descriptor.value (c:\\nocobase\\XXX\\node_modules\\@nocobase\\database\\lib\\collection.js:71:29)\n    at c:\\nocobase\\XXX\\node_modules\\@nocobase\\plugin-data-source-main\\dist\\server\\models\\field.js:65:25\n    at async model.load (c:\\nocobase\\XXX\\node_modules\\@nocobase\\plugin-data-source-main\\dist\\server\\models\\field.js:63:19)\n    at async model.loadFields (c:\\nocobase\\XXX\\node_modules\\@nocobase\\plugin-data-source-main\\dist\\server\\models\\collection.js:137:7)\n    at async CollectionRepository.load (c:\\nocobase\\XXX\\node_modules\\@nocobase\\plugin-data-source-main\\dist\\server\\repositories\\collection-repository.js:130:7)\n    at async _AsyncEmitter.loadCollections (c:\\nocobase\\XXX\\node_modules\\@nocobase\\plugin-data-source-main\\dist\\server\\server.js:339:7)\n    at async _AsyncEmitter.emitAsync (c:\\nocobase\\XXX\\node_modules\\@nocobase\\utils\\lib\\mixin\\AsyncEmitter.js:66:7)\n    at async _AsyncEmitter.start (c:\\nocobase\\XXX\\node_modules\\@nocobase\\server\\lib\\application.js:662:5)\n    at async _AppCommand.<anonymous> (c:\\nocobase\\XXX\\node_modules\\@nocobase\\server\\lib\\commands\\start.js:80:5)\n    at async _AppCommand.parseAsync (c:\\nocobase\\XXX\\node_modules\\@nocobase\\server\\node_modules\\commander\\lib\\command.js:935:5)\n    at async _AsyncEmitter.runAsCLI (c:\\nocobase\\XXX\\node_modules\\@nocobase\\server\\lib\\application.js:609:23)","meta":{},"module":"application","submodule":"","method":"","app":"main","reqId":"c76c1098-4bc9-4085-a4dc-bfc610b91b9c","dataSourceKey":"main","timestamp":"2026-01-08 09:42:22"}

Could it be related to collation?

After deleting the entire app, I reinstalled everything and I end up in the same error.
Very curious, as on this machine it was running without errors for several months!

solved it myself
– the server changed to MariaDB instead of MySQL.
After I reinstalled with the option mariadb everything works.

I also encountered this problem. My collection lost its primary key and therefore the application is throwing an error:

Target model collection* has no primary key attribute.
*collection - custom collection

I can see there’s also a topic raised on the issue [App error - Collection model roles has no primary key attribute · Issue #4037 · nocobase/nocobase · GitHub](App error - Collection model roles has no primary key attribute)

As I can see, there’s no solution yet.

What type of database is it? What is the environment variable DB_DIALECT set to?

DB_DIALECT=postgres
data base postgres16

I tried changing APP_KEY

I corrected the value of the options column in the database for the id row of the problematic collection.
added

"autoIncrement": true,
  "primaryKey": true,

image
was

{
    "isForeignKey": true,
    "uiSchema": {
        "type": "number",
        "title": "id",
        "x-component": "InputNumber",
        "x-read-pretty": true
    },
    "overriding": true
}