How to change automatic setting of Foreign-key constraint to admin_users

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

Can anyone tell me why by default Strapi creates a foreign-key constraint on admin_users? Or could this be some sort of global setting that I’m missing. When I create a new Collection there’s an automatic constraint set, but why would it be set to admin_users? It seems like it should be set to the users table.

“testings_created_by_id_fk” FOREIGN KEY (created_by_id) REFERENCES admin_users(id) ON DELETE SET NULL

If someone is creating a new transaction, chances are they’re not an admin. I know Strapi enforces having the foreign key constraint, but this seems off. It’s happening on the created_by_id and upated_by_id, which wouldn’t always be an admin.

It seems like Strapi doesn’t even populate this column, even though they create it for each table and put the constraint on it.

The bottom two records I did through the generic Strapi route, the tops ones I needed to use Knex and create the transaction myself.


1 Like

Were you able to find a fix?