love NocoDB and its look and feel really a lot. But before I make the switch from my paid Airtable subscription, I need to understand one thing: To me it looks there is no way to make a column “unique” (e. g. only unique product numbers or something like this).
Can that really be because from my point of view that would be a very basic feature so I am assuming I am overseeing something.
Unique constraint for a column is currently not available in NocoDB. We are working on it. Note that, this would be an enterprise / paid feature requiring license to use in Self hosted environment.
Given that my NGO has not subscribed to a Licence, I have tried to set the constraint manually in my self-hosted (docker) installation, via a Postgres client : ALTERTABLEmy_schema.my_tableADDCONSTRAINT"my_table_unique_email"UNIQUE (email)
The request is accepted by the database. However, when importing records afterwards (via UI, in CSV format), NocoDB rejects all raws with the error : “Database rejected the row”. And the docker logs show : "msg":"Bulk insert failed for batch of 24 rows at row ~24: unknown field unique constraint violation."}
But the manual add of a single row is possible, as long as it respects the newly added constraint. Otherwise I get the message : Failed to insert row: courriel field unique constraint violation. Value 'test' already exists. which is correct.
=> Is this import error a bug, or a direct way of placing “unique columns” behing the Licencing paywall ?
This isn’t really a bug or a paywall trick — the issue is that you directly modified the Postgres database, which NocoDB manages as a native base.
NocoDB keeps its own metadata layer describing your tables and columns. When you add a constraint via a Postgres client, the real schema changes but NocoDB’s metadata doesn’t know about it, so the two go out of sync. That desync is what produces the vague “unknown field unique constraint violation” on bulk import.
You should never directly modify a Postgres database that’s a native NocoDB base — it puts the metadata and schema out of sync and can cause further problems down the line (broken views, failed migrations, etc.). I’d recommend dropping the manually added constraint to get back to a consistent state, and handling deduplication outside NocoDB (e.g. dedupe the CSV before importing) until the native unique-column feature ships.
I get that, thanks for putting your thoughts to it! Indeed reverting the constraint solved the errors (but not my need )
I think the feature already shipped, only it’s limited to Business licences. But what I can try is resync the schemas (from DB connection/Data source), I’ll tell you how it goes…
So, it turns out you can sync manual DB changes on external DB source ( Sync with Data source ) but not on internal NocoDB sources. That’s a bit sad
The 2 options to get the feature are then :
Get a Business Licence
Use external Data Source, either with another DBserver or with the same DB container (in which case you must use 172.17.0.1 as IP address, because of the 2 containers docker setting).