How to make the auto generated ID unique values not auto incremented

System Information
  • Strapi Version: “3.4.3”
  • Operating System: MacOS
  • Database: postgres
  • Node Version: 14.12.0
  • NPM Version: 6.14.8
  • Yarn Version: 1.22.5

How to make the auto generated ID unique values not auto incremented? I’m using Postgres as my database

I tried the beforeCreate method and I wasn’t able to change the id value, can you help me with this?

I tried this on create hooks

const { v4: uuidv4 } = require(“uuid”);

module.exports= {
lifecycles: {
async beforeCreate(data) {
data.id = uuidv4();
},
},
};

Currently we don’t support UUID on SQL databases (yet) nor do we support Int IDs on MongoDB, we did have this feature but it was removed before we went stable and do plan to take another look in Q3. The reason for this was due to a lot of refactoring required within the code base to remove hard coded type checks (Int vs string).

See this FAQ for more info: Troubleshooting | Strapi Developer Documentation

Was there any update to this?

Hi Strapi,

I hope you are doing well.

Currently, we will try to adjust some code within your codebase to integrate with our current database model. I hope that you can finish the code refactoring in Q3 following your release plan so that we can upgrade to the very clean code version of Strapi.

Regards, Nhat Nguyen

It would be great, if this feature is implemented on the next releases, having the flexability to change the current incremental auto generated unique ID…