Issue
When I set unique constraints to a column on Salesforce, it's not reflected in the database. Can I manually add it to the database, too? In addition to that, can I also add other constraints such as Not-Null constraints?
Resolution
While synced records must be unique in the database when the unique option is set in Salesforce, you can also set the constraints to the column in the database to avoid insert duplications if it is read/write mapping. Please note that Salesforce unique constraints can be either case sensitive or case insensitive while it is case sensitive in Postgres. If you want to set it as case insensitive in the database, an approach is to create a function index, for example, UPPER(column_name)
.
Regarding other constraints, you should not set Not-Null and Foreign Keys constraints. It will cause sync issues when reloading the mapping object. Primary Keys is already used, and you can't set it. Check and Exclusion Constraints can be added but Salesforce doesn't have such a constraint. That inconsistency may cause sync issues, and we don't recommend using these constraints.
Please note that recreating the mapping or importing the config file will remove the constraint in the database.