Hello everyone am following a tutorial blog on medium titled Part 13 — Ash Framework for Phoenix Developers | Multitenancy - SAAS
now, while following this instruction
Finally, we need to update all other resources (except users, teams, and user_teams) to inform Ash that they are multi-tenant resources. Add the following block to each resource:
# Make this resource multi-tenant
multitenancy do
strategy :context
end
Unfortunately i forgot to add that code to one of the resources(token)
i went ahead and did the following instructions
Let’s generate migrations for our multi-tenant schema by running:
mix ash_postgres.generate_migrations add_multitenancy_tables
Then, run the migrations with: mix ash_postgres.migrate
If you open an IEx session with iex -S mix and run:
Ash.create!(Helpcenter.Accounts.Team, %{name: "Zippiker", domain: "zippiker"})
During inspection of my database it’s when i discovered that a table for token was not created. this has affected me greatly in the next tutorials as i ran into such errors
1) test User tests: User creation - creates personal team automatically (Zippiker.Accounts.UserTest)
test/zippiker/accounts/user_test.exs:8
** (Ash.Error.Unknown)
Bread Crumbs:
> Exception raised in: Zippiker.Accounts.User.register_with_password
Unknown Error
* ** (MatchError) no match of right hand side value: :error
(ash_authentication 4.5.2) lib/ash_authentication/generate_token_change.ex:46: AshAuthentication.GenerateTokenChange.generate_token/4
(ash_authentication 4.5.2) lib/ash_authentication/generate_token_change.ex:19: anonymous fn/4 in AshAuthentication.GenerateTokenChange.change/3
(ash 3.4.63) lib/ash/changeset/changeset.ex:4066: anonymous fn/2 in Ash.Changeset.run_after_actions/3
(elixir 1.18.1) lib/enum.ex:4964: Enumerable.List.reduce/3
(elixir 1.18.1) lib/enum.ex:2600: Enum.reduce_while/3
(ash 3.4.63) lib/ash/changeset/changeset.ex:3544: anonymous fn/3 in Ash.Changeset.with_hooks/3
(ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1400: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
(db_connection 2.7.0) lib/db_connection.ex:1756: DBConnection.run_transaction/4
(ash 3.4.63) lib/ash/changeset/changeset.ex:3542: anonymous fn/3 in Ash.Changeset.with_hooks/3
(ash 3.4.63) lib/ash/changeset/changeset.ex:3686: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
(ash 3.4.63) lib/ash/changeset/changeset.ex:3523: Ash.Changeset.with_hooks/3
(ash 3.4.63) lib/ash/actions/create/create.ex:260: Ash.Actions.Create.commit/3
(ash 3.4.63) lib/ash/actions/create/create.ex:132: Ash.Actions.Create.do_run/4
(ash 3.4.63) lib/ash/actions/create/create.ex:50: Ash.Actions.Create.run/4
(ash 3.4.63) lib/ash.ex:2222: Ash.create!/3
test/zippiker/accounts/user_test.exs:17: Zippiker.Accounts.UserTest."test User tests: User creation - creates personal team automatically"/1
(ex_unit 1.18.1) lib/ex_unit/runner.ex:511: ExUnit.Runner.exec_test/2
(stdlib 6.2) timer.erl:595: :timer.tc/2
(ex_unit 1.18.1) lib/ex_unit/runner.ex:433: anonymous fn/6 in ExUnit.Runner.spawn_test_monitor/4
code: Ash.create!(
stacktrace:
(ash_authentication 4.5.2) lib/ash_authentication/generate_token_change.ex:46: AshAuthentication.GenerateTokenChange.generate_token/4
(ash_authentication 4.5.2) lib/ash_authentication/generate_token_change.ex:19: anonymous fn/4 in AshAuthentication.GenerateTokenChange.change/3
(ash 3.4.63) lib/ash/changeset/changeset.ex:4066: anonymous fn/2 in Ash.Changeset.run_after_actions/3
(elixir 1.18.1) lib/enum.ex:4964: Enumerable.List.reduce/3
(elixir 1.18.1) lib/enum.ex:2600: Enum.reduce_while/3
(ash 3.4.63) lib/ash/changeset/changeset.ex:3544: anonymous fn/3 in Ash.Changeset.with_hooks/3
(ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1400: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
(db_connection 2.7.0) lib/db_connection.ex:1756: DBConnection.run_transaction/4
(ash 3.4.63) lib/ash/changeset/changeset.ex:3542: anonymous fn/3 in Ash.Changeset.with_hooks/3
(ash 3.4.63) lib/ash/changeset/changeset.ex:3686: anonymous fn/2 in Ash.Changeset.transaction_hooks/2
(ash 3.4.63) lib/ash/changeset/changeset.ex:3523: Ash.Changeset.with_hooks/3
(ash 3.4.63) lib/ash/actions/create/create.ex:260: Ash.Actions.Create.commit/3
(ash 3.4.63) lib/ash/actions/create/create.ex:132: Ash.Actions.Create.do_run/4
(ash 3.4.63) lib/ash/actions/create/create.ex:50: Ash.Actions.Create.run/4
(ash 3.4.63) lib/ash.ex:2222: Ash.create!/3
test/zippiker/accounts/user_test.exs:17: (test)
Finished in 0.8 seconds (0.00s async, 0.8s sync)
1 test, 1 failure
which i believe originate from that mistaken.
i have laboured to find the solution, but all in vain, how can i solve this