mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
be23b6e89b
* 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.