-
- Downloads
Add `updated_by` to API Keys (#37014)
This required a bit of modification of the DB. First, I had named the column meant to hold the ID of the user who last updated an API key as `updated_by`. But it seemed like `updated_by` was the natural field to hold the user name that FE wanted, and I didn't want to clobber an existing field with `hydrate`. So, I renamed the existing column to `updated_by_id` and used `updated_by` to hold the hydrated user that updated the ApiKey. Second, for consistency, I renamed `created_by` to `creator_id`. The logic for presenting an ApiKey was getting a bit complicated and spread out over many different endpoints, so I pulled it out into its own function that's called from almost every endpoint defined in the `metabase.api.api-key` namespace. Note that it calls `(t2/hydrate api-key :updated_by :group_name)` - but I verified that this will not result in additional DB calls if the model was already hydrated.
Showing
- resources/migrations/001_update_migrations.yaml 46 additions, 0 deletionsresources/migrations/001_update_migrations.yaml
- src/metabase/api/api_key.clj 43 additions, 24 deletionssrc/metabase/api/api_key.clj
- src/metabase/models/api_key.clj 12 additions, 2 deletionssrc/metabase/models/api_key.clj
- src/metabase/models/user.clj 4 additions, 3 deletionssrc/metabase/models/user.clj
- test/metabase/api/api_key_test.clj 40 additions, 28 deletionstest/metabase/api/api_key_test.clj
- test/metabase/server/middleware/session_test.clj 23 additions, 20 deletionstest/metabase/server/middleware/session_test.clj
Please register or sign in to comment