Fix serialization P2 issues (#17388)
* Fix serialization dump error when there are no collections Update `select-collections` to correctly handle the case where there are no collections Adding new test that removes all collections, then ensures that dump works with no errors * Fix serialization load error into empty/blank target DB Rethrowing exception in cmd when overall load fails Add test to ensure that a dump containing a user can be loaded into a blank target app DB successfully Adding a few missing bindings to the `with-temp-empty-app-db` code to set the connection vars under metabase.db.connection In upsert, add hooks for a :pre-insert-fn and :post-insert-fn to be invoked for new entity instances created by the upsert process, since whether an entity will be an insert or update isn't necessarily known by the load process (only by upsert once identity-condition is checked for each) In load, setting the pre and post insert functions for a User instance to initialize :password with a random value, and to generate and send a password reset email to the newly inserted user's email, respectively NOTE: this post insert fn (to send a password reset email for newly inserted users) is NOT hooked up for User as of x.41 release, since it is considered a bugfix, but this can be enabled in a future release) Adding new defs for the magic permission group names to make those easier to override from tests that might need to (such as the one added for this commit) * Fix serialization objects being incorrectly updated on skip Remove `maybe-fixup-card-template-ids!`, which was forcing mode :update, since the existing retry logic should cover what it was trying to do Update Card and Metric models to delete any Dependency instances for which they are the `:model_id` (to make serialization tests after other tests created temporary Card/Dependency pairs) Adding missing assertions for Dependency serialization * Serialization: Fix reload entity logic Now that the `:mode` is always respected instead of being ignored sometimes, we need to update our "second pass" reload functions to always make the mode `:update` on the second pass, or else that entity would just be skipped, which is bad Also updated the test to use `:mode` `:skip` from the beginning to be more stringent
Showing
- enterprise/backend/src/metabase_enterprise/serialization/cmd.clj 11 additions, 8 deletions...ise/backend/src/metabase_enterprise/serialization/cmd.clj
- enterprise/backend/src/metabase_enterprise/serialization/load.clj 39 additions, 17 deletions...se/backend/src/metabase_enterprise/serialization/load.clj
- enterprise/backend/src/metabase_enterprise/serialization/upsert.clj 15 additions, 14 deletions.../backend/src/metabase_enterprise/serialization/upsert.clj
- enterprise/backend/test/metabase_enterprise/serialization/cmd_test.clj 73 additions, 0 deletions...ckend/test/metabase_enterprise/serialization/cmd_test.clj
- enterprise/backend/test/metabase_enterprise/serialization/load_test.clj 2 additions, 2 deletions...kend/test/metabase_enterprise/serialization/load_test.clj
- enterprise/backend/test/metabase_enterprise/serialization/serialize_test.clj 4 additions, 3 deletions...test/metabase_enterprise/serialization/serialize_test.clj
- enterprise/backend/test/metabase_enterprise/serialization/test_util.clj 7 additions, 2 deletions...kend/test/metabase_enterprise/serialization/test_util.clj
- src/metabase/cmd.clj 2 additions, 2 deletionssrc/metabase/cmd.clj
- src/metabase/models/card.clj 3 additions, 2 deletionssrc/metabase/models/card.clj
- src/metabase/models/metric.clj 6 additions, 2 deletionssrc/metabase/models/metric.clj
- src/metabase/models/permissions_group.clj 18 additions, 3 deletionssrc/metabase/models/permissions_group.clj
- test/metabase/db/schema_migrations_test/impl.clj 17 additions, 7 deletionstest/metabase/db/schema_migrations_test/impl.clj
Loading
Please register or sign in to comment