How to change the schema definition using SQL data source

Hi everyone

I would like to know if there is a way to change/intervene in the introspection that takes place in the SQL databases by the Forest Admin Agent.

In this case I would like to define that for my database field called guid, it will be created with the default value when creating a record for example: { guid: bud_${ulid()} } };`; this value will be defined using the ulid package.

The above works for me, however, it is not what I want, since at the moment of creating a new record from the dashboard the input is enabled allowing it to be manipulable, and what I want to achieve for better behavior is that this value is taken as the id and is not modifiable.


  • Project name: wallet-forestadmin
  • Team name: Operations
  • Environment name: FL0 Production
  • Agent (forest package):
    “dependencies”: {
    @forestadmin/agent”: “^1.36.13”,
    @forestadmin/datasource-mongoose”: “^1.5.33”,
    @forestadmin/datasource-sql”: “^1.7.44”,
  • Database type: PostgreSQL

You can add a read only constraint on your field, by adding a constraint on your layout with setting. Does my answer help you?

Hi Alban, thank you for replying,

Unfortunately no. If I set it to read-only from the dasboard I get this error after trying to make a record.

    "errors": [
            "name": "ValidationError",
            "detail": "SequelizeDatabaseError: target: wallet-testing.-.primary: vttablet: rpc error: code = Unknown desc = Field 'guid' doesn't have a default value (errno 1364) (sqlstate HY000) (CallerID: iwhsy5wwxhth5km7kgft): Sql: \"insert into budget(portal_id, `name`, `status`, currency, created_time, updated_time) values (:vtg1 /* VARCHAR */, :vtg2 /* VARCHAR */, :vtg3 /* INT64 */, :vtg4 /* VARCHAR */, current_timestamp(3), :vtg5 /* VARCHAR */)\", BindVars: {REDACTED}",
            "status": 400

I also want to mention that the scope is to use MySQL and MongoDB database connections. For the case of the databases with MongoDB, my implementation was easily solved by defining the schema

 new Mongoose.Schema({
    _id: {
      type: String,
      default: () => `lr_${ulid()}`

And since for SQL databases, I do an introspection of my tables, I don’t know how to define something similar to what I did in Mongoose

Hello again :slight_smile:
It’s little bit weird, your error is from your database and it wants to have a default value for your non null field. Have you defined a default value for this field in your database?