Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserIdentity: Too long index names #733

Open
rhblind opened this issue Jun 25, 2024 · 0 comments
Open

UserIdentity: Too long index names #733

rhblind opened this issue Jun 25, 2024 · 0 comments

Comments

@rhblind
Copy link

rhblind commented Jun 25, 2024

After this commit on AshPostgres, indices generated on user identities may easily be too long.

Identity module

defmodule MyApp.Domain.Account.UserIdentity do
  use Ash.Resource,
    domain: MyApp.Domain.Account,
    data_layer: AshPostgres.DataLayer,
    extensions: [AshAuthentication.UserIdentity]

  user_identity do
    domain MyApp.Domain.Account
    user_resource MyApp.Domain.Account.User
  end

  postgres do
    repo MyApp.AshRepo
    table "account_user_identity"
  end
end

Traceback

** (EXIT from #PID<0.98.0>) an exception was raised:
    ** (Spark.Error.DslError) [MyApp.Domain.Account.UserIdentity]
postgres -> identity_index_names -> account_user_identity_unique_on_strategy_and_uid_and_user_id_index:
  Identity unique_on_strategy_and_uid_and_user_id has a name that is too long. Names must be 63 characters or less.

Please configure an index name for this identity in the `identity_index_names` configuration. For example:application

postgres do
  identity_index_names :unique_on_strategy_and_uid_and_user_id: "a_shorter_name"
end

        (ash_postgres 2.0.12) lib/verifiers/validate_identity_index_names.ex:43: anonymous fn/2 in AshPostgres.Verifiers.ValidateIdentityIndexNames.verify/1
        (elixir 1.16.3) lib/enum.ex:992: anonymous fn/3 in Enum.each/2
        (stdlib 5.2) maps.erl:416: :maps.fold_1/4
        (elixir 1.16.3) lib/enum.ex:2540: Enum.each/2
        (ash_postgres 2.0.12) lib/verifiers/validate_identity_index_names.ex:30: AshPostgres.Verifiers.ValidateIdentityIndexNames.verify/1
        lib/myapp/domain/account/resources/identity.ex:1: anonymous fn/1 in 
MyApp.Domain.Account.UserIdentity.__verify_spark_dsl__/1
        (elixir 1.16.3) lib/enum.ex:987: Enum."-each/2-lists^foreach/1-0-"/2
        lib/myapp/domain/account/resources/identity.ex:1: MyApp.Domain.Account.UserIdentity.__verify_spark_dsl__/1

The generated index account_user_identity_unique_on_strategy_and_uid_and_user_id_index is 66 characters long, while the changes introduced in AshPostgres limits indices to maximum 63 characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant