Files
Christophe Bliard be23b6e89b Fix error when users table does not exist (#21482)
* Fix error when users table does not exist

In multitenant context, when schema is switched to and the tables are
not created yet, getting `User.current` will fail with

    ActiveRecord::StatementInvalid:"PG::UndefinedTable: ERROR:  relation \"users\" does not exist" [...]

To prevent it, check if the table exists first and return `nil` if not.

* Avoid logging "slow sql" for database creation

* Better performance for handling unexisting users table

Checking multiple times the users table existence when something is
logged is probably a bad idea. Better rescue errors.

Also cache the return value of `#current_user` to call the method only
once.
2025-12-18 15:12:26 +01:00
..