`:ci_string` not becoming `citext` with `Ash.Type.NewType`

In my migrations:
add :email, :text, null: false
add :email, :text, null: false
I've solved this with casing: :lower for the example above, but there are fields where I'd like to preserve casing.
13 Replies
ZachDaniel
ZachDaniel3y ago
Interesting...right you are can you try ash_postgres main?
\ ឵឵឵
\ ឵឵឵OP3y ago
Yep
** (KeyError) key :constraints not found in: %{allow_nil?: false, default: &Ash.UUID.generate/0, generated?: false, name: :id, primary_key?: true, source: :id, type: Ash.Type.UUID}
** (KeyError) key :constraints not found in: %{allow_nil?: false, default: &Ash.UUID.generate/0, generated?: false, name: :id, primary_key?: true, source: :id, type: Ash.Type.UUID}
ZachDaniel
ZachDaniel3y ago
ah...yeah okay okay try again?
\ ឵឵឵
\ ឵឵឵OP3y ago
Still getting :text
ZachDaniel
ZachDaniel3y ago
Hmm....it should be working
iex(2)> AshPostgres.MigrationGenerator.get_migration_type(Ash.Type.NewType, subtype_of: :ci_string)
:citext
iex(3)> AshPostgres.MigrationGenerator.get_migration_type(Ash.Type.NewType, subtype_of: Ash.Type.CiString)
:citext
iex(2)> AshPostgres.MigrationGenerator.get_migration_type(Ash.Type.NewType, subtype_of: :ci_string)
:citext
iex(3)> AshPostgres.MigrationGenerator.get_migration_type(Ash.Type.NewType, subtype_of: Ash.Type.CiString)
:citext
can I see your newtype?
\ ឵឵឵
\ ឵឵឵OP3y ago
defmodule App.Type.Email do
use Ash.Type.NewType,
subtype_of: :ci_string,
constraints: [
casing: :lower,
match:
~r/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
]
end
defmodule App.Type.Email do
use Ash.Type.NewType,
subtype_of: :ci_string,
constraints: [
casing: :lower,
match:
~r/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
]
end
ZachDaniel
ZachDaniel3y ago
🤔 🤔 🤔 can you delete the other snapshots/migrations and regenerate? Should be working as far as I can tell and you did mix deps.update ash_postgres?
\ ឵឵឵
\ ឵឵឵OP3y ago
Wait a minute. Nope, yeah:
add :text, :text, null: false
add :text, :text, null: false
ZachDaniel
ZachDaniel3y ago
can you confirm the git ref you're on for ash_postgres? Just want to be 100% sure because I don't see how it would still be doing that
\ ឵឵឵
\ ឵឵឵OP3y ago
I was poking around in the middle with subtype_of: :string and casing: lower, but I had already put it back to test. c72210adffd552e4517c5d21d84e2f07aaae5d85 Looks old But pull there says it's up-to-date Same ref I see on github fwiw
ZachDaniel
ZachDaniel3y ago
wow, sorry Just a slow morning for me I guess okay, this time for real 😄
\ ឵឵឵
\ ឵឵឵OP3y ago
Looks good, working against existing columns Thanks mate
ZachDaniel
ZachDaniel3y ago
My pleasure. I'll cut a release 🙂

Did you find this page helpful?