kotlinkotlin-exposed

How to set an default schema for all transaction in exposed


I'm using Kotlin with Exposed to create and manage tables in my PostgreSQL database. I also have a custom schema, and I set it for each transaction like this:

transaction(master.database) {
    SchemaUtils.setSchema(Schema(master.schema))
    // other operations
}

However, it feels redundant to specify the schema in every single transaction. Is there a way to set a default schema for all transactions globally, so I don’t have to repeat this in each one?

Thank you!


Solution

  • There is a defaultSchema in DatabaseConfig, so you can set it when defining your master.database