Skip to content

Commit

Permalink
improvement: support :ci_string as a storage_type
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Oct 10, 2023
1 parent 772c12b commit 9f62d65
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions lib/migration_generator/migration_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2743,6 +2743,7 @@ defmodule AshPostgres.MigrationGenerator do
end

defp migration_type_from_storage_type(:string), do: :text
defp migration_type_from_storage_type(:ci_string), do: :citext
defp migration_type_from_storage_type(storage_type), do: storage_type

defp foreign_key?(relationship) do
Expand Down
14 changes: 0 additions & 14 deletions lib/types/ci_string_wrapper copy.ex

This file was deleted.

10 changes: 5 additions & 5 deletions lib/types/ci_string_wrapper.ex
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
defmodule Ash.Type.StringWrapper do
defmodule Ash.Type.CiStringWrapper do
@moduledoc false
use Ash.Type

@impl true
def storage_type(_), do: :text
def storage_type(_), do: :citext

@impl true
defdelegate cast_input(value, constraints), to: Ash.Type.String
defdelegate cast_input(value, constraints), to: Ash.Type.CiString
@impl true
defdelegate cast_stored(value, constraints), to: Ash.Type.String
defdelegate cast_stored(value, constraints), to: Ash.Type.CiString
@impl true
defdelegate dump_to_native(value, constraints), to: Ash.Type.String
defdelegate dump_to_native(value, constraints), to: Ash.Type.CiString
end
14 changes: 14 additions & 0 deletions lib/types/string_wrapper.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule Ash.Type.StringWrapper do
@moduledoc false
use Ash.Type

@impl true
def storage_type(_), do: :text

@impl true
defdelegate cast_input(value, constraints), to: Ash.Type.String
@impl true
defdelegate cast_stored(value, constraints), to: Ash.Type.String
@impl true
defdelegate dump_to_native(value, constraints), to: Ash.Type.String
end

0 comments on commit 9f62d65

Please sign in to comment.